Backup of persistent memory

You need available space on a partition to create backups from the persistent memory of your flash disk installation. Copy kn-backup.sh at '/usr/sbin/' and make it executable with "chmod 744" (Download).

Caution: if you want to use "incremental backup" you have to use a partition formatted with a Linux-filesystem (not NTFS or FAT).

Principles of backup

  • KNOPPIX contains the compressed filesystem
  • knoppix-data.img (.aes) is the persistent memory (within an overlay file) and contains
    → new installed packages and new files
    → markings about deleted packages and files within KNOPPIX
  • New: in case you have selected persistent memory within an overlay partition you'll find the content of persistent memory in partition #2 of your flash disk install
  • UNIONFS merges (decompressed) KNOPPIX with persistent memory

 Whole or incremental backups

kn-backup9
 
  • Backup whole persistent memory
    → save all from persistent memory as a .tar.gz-file
    → write a notice in a commentfile
  • Backup personal persistent memory
    → save '/etc/' and '/home/' from persistent memory as a .tar.gz-file
    → write a notice in a commentfile
  • Create incremental backup
    → save changes of persistent memory in between times in a daily.n-folder
    → rotate all daily.n by one number (totally 10 daily.n-folders)

 

kn-backup2

 

kn-backup3

 

kn-backup4
 
  • Restore elder (whole/personal) backup
    → displays for selection notices of commentfiles
    → creates a special script '/mnt-system/bufi'

 

kn-backup5

 

  • Repair persistent memory with incremental backup
    → display existing backup-folders
    → reset all within persistent memory to the state of the selected daily.n-folder

 

kn-backup11
 
  • Restore respectively Repair
    → demand to close all other running applications
    → last action of the backup and reboot of Knoppix

 

kn-backup10

 

 Top

Create menu entry

Copy the following script as kn-backup.desktop to the directory '/usr/share/applications'and you'll get the menu entry "Overlay backup" within the group Sytem tools.

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=Overlay backup
Name[de]=Backup Overlay
Comment=Create backups of persistent memory
Comment[de]=Backups vom persistent memory erstellen
Icon=accessories-dictionary
Exec=su-to-root -X -c "/usr/bin/lxterminal --geometry=100x24 -e /usr/sbin/kn-backup.sh"
Terminal=false
StartupNotify=true
Categories=System;

 Top

Incremental Backup as Cron-Job

If you like to save changes of persistent memory in between times by a cronjob you can use the following script.

Copy it as kn-cron-backup.sh to the directory '/usr/sbin' and create the cronjob as root with "crontab -e".  Within the script you have to declare the value of the variable PFAD as you need it. Caution: you can only use a partition formatted with a Linux-filesystem (not NTFS):

#! /bin/bash
#----------------------------------------------------------------------
# kn-cron-incremental.sh (V0.1-1)
# Description: Create incremental backup of persistent memory
# from flash disk installation.
# Use script within a cronjob.
# Author: Werner P. Schulz <
 Diese E-Mail-Adresse ist vor Spambots geschützt! Zur Anzeige muss JavaScript eingeschaltet sein!>
# Created at: Sa Mai 25 12:13 CEST 2013
# License: This file is licensed under the GPL v3.
#----------------------------------------------------------------------
# Insert value of partiton you want to use
# For example: PFAD="/media/sdb2"
PFAD=""
if [ "$PFAD" = "" ]; then
  echo "No value for variable 'PFAD'!"; exit
fi
if ! [ -d $PFAD/knx/bufi/incr ]; then
  mkdir $PFAD/knx/bufi/incr
fi
ls $PFAD/knx/bufi/incr
if ! [ -d $PFAD/knx/bufi/incr/daily.0 ] ; then
  mkdir -p $PFAD/knx/bufi/incr/daily.0
fi
clear
setterm -cursor off
tput cup  19 1
rsync -av --numeric-ids --delete --delete-after --exclude=*/Cache/*  \
  /KNOPPIX-DATA/ $PFAD/knx/bufi/incr/daily.0 \
  | awk '{printf "%-78s\r", substr($1, 1, 78)}'
setterm -cursor on
if ! [ $? = 24 -o $? = 0 ] ; then
  echo"Fatal: rsync 'persistent memory' finished with errors!"
fi
touch $PFAD/knx/bufi/incr/daily.0
if [ -d $PFAD/knx/bufi/incr/daily.9 ] ; then
  rm -rf $PFAD/knx/bufi/incr/daily.9
fi
# rotate snapshots
for OLD in 9 8 7 6 5 4 3 2 1  ; do
  if [ -d $PFAD/knx/bufi/incr/daily.$OLD ] ; then
	NEW=$[ $OLD + 1 ]
	touch $PFAD/knx/bufi/.timestamp -r $PFAD/knx/bufi/incr/daily.$OLD
	mv $PFAD/knx/bufi/incr/daily.$OLD $PFAD/knx/bufi/incr/daily.$NEW
	touch $PFAD/knx/bufi/incr/daily.$NEW -r $PFAD/knx/bufi/.timestamp
  fi
done
if [ -d $PFAD/knx/bufi/incr/daily.0 ] ; then
  cp -al $PFAD/knx/bufi/incr/daily.0 $PFAD/knx/bufi/incr/daily.1
fi
sync
echo "Finished incremental backup via cronjob"

 Top