This is how I take backup of my data. Might be useful. I have 8GB pen drive, with encrypted partition. On boot partition is mounted manually with root password. Data is backed up every 10 minutes to the USB disk. Yes 8GB is enough for my work mostly c,c++ code, pdfs. On login one script runs, causing beep,beep... on PC speaker, this reminds me to mount backup partition.
1. Script to create encrypted partition. This is done once when creating backup partition.
#!/bin/sh #Usage #create_crypt_fs.sh Device_Path Size DEV=$1 SIZE=$2 dd if=/dev/zero of=$DEV bs=1024 count=$SIZE chmod 600 $DEV losetup /dev/loop0 $DEV cryptsetup -y luksFormat /dev/loop0 cryptsetup luksOpen /dev/loop0 $DEV mke2fs -j /dev/mapper/$DEV #1 end script
2. Script to take backup every 10minutes. This is run from cron.
- put your backup dir here
DIRS="/home/bal/Projects/ .gnupg .kde /home/bal/WindowsProjects /home/bal/.gnome2" SIZE=0 TOTAL_SIZE=0 BACKUP_DIR="/mnt/backup/bal" #for DIR in $DIRS; do # SIZE=`du -sb $DIR|cut -f1` # echo -e "$DIR \t\t\t\t$SIZE"; # TOTAL_SIZE=$((TOTAL_SIZE+SIZE)) #done #echo -e "Total \t\t\t\t\t$TOTAL_SIZE" cd $BACKUP_DIR for DIR in $DIRS;do echo "Syncing $DIR" rsync -a -e --delete $DIR $BACKUP_DIR done echo `date` > $BACKUP_DIR/backup.time #2 end script
3. Alert to mount script on every login, this is run from system->preferences->sessions as 'xterm /home/bal/Projects/Scripts/backup_monitor.sh'
while [ "1" ]; do
if [ ! -f "/mnt/backup/bal/backup.time" ]; then echo -n "Backup error" echo $'\a' sleep 1 else cat /mnt/backup/bal/backup.time; sleep 10 fi clear
4. To mount encrypted FS when you login.
DEV=`ls /dev/disk/by-id/| grep SanDisk_Cruzer_43215213BA824F0A|grep part1` if [ "$DEV" ]; then
echo "Trying to mount /dev/disk/by-id/$DEV as backup device" mount /dev/disk/by-id/$DEV /mnt/usb losetup /dev/loop0 /mnt/usb/backup cryptsetup luksOpen /dev/loop0 backup mount /dev/mapper/backup /mnt/backup/
echo "Backup USB device not found" echo "Please insert proper usb disk"
fi Thanks and Regards Balwinder Singh