NOTE: This script will not work on Statler without a custom install of remastersys. However the incremental backups bit of the code is still good.
For a while now I've been trying to find the best backup solution for myself--and think I may have it close to pinned down for my own needs. Thought I'd share it with others in case someone is looking for ones, or has tips to clean it up. It is my first script beyond editing autostarts and the like.
The goals of the script are as follows:
1) Create a backup of set directory to external media
2) Move all files changed since last backup into a dated file (on backup drive.)
3) Have option to create a new LiveCD iso at the same time via remastersys.
4) Move that LiveCD iso onto external media.
When run, there are two backup options:
1) "Normal" This will backup the specified directory and dump all changed and/or deleted files into a dated folder.
2) "Normal+LiveCD" This runs a normal backup, then creates a LiveCD and puts the dated iso onto the backup media before cleaning out the build directory.
I've tried to make it as easy to move between systems as possible--as i do myself on a daily basis. All the user 'should' have to edit are the variable paths to be appropriate for their system. It runs in a terminal, just requires user to make it executable (chmod +x /pathofscript).
Please feel free to leave any comments / feedback--I'm very new to this.
#!/bin/bash ##Variables BACKUPTIME="`date +%m_%d_%Y`" SOURCEDIR="/home/jake" BACKUPDIR="/media/crunchbackups/home" INCREMENTS="/media/crunchbackups/backup/$BACKUPTIME" EXCLUDES="/home/jake/bin/backupexcludes.txt" SOURCEISO="/home/jake/distbackup/remastersys/crunchbang_deskspin_$BACKUPTIME.iso" BACKUPISOS="/media/crunchbackups/backup/isos/" PS3="Choose (1-3):" echo "" echo "Select the backup type with correct number:" select type in Normal Normal+LiveCD Cancel do break done read -p "Please mount backup drive and hit enter to continue..." nothing if [ "$type" = "Normal" ]; then sudo mkdir $INCREMENTS echo "Running rsync backup..." sleep 2s sudo rsync -acb --progress --exclude-from="$EXCLUDES" --backup-dir=$INCREMENTS $SOURCEDIR $BACKUPDIR echo "Normal backup on $BACKUPTIME complete." echo "Thank you for your diligence." else if [ "$type" = "Normal+LiveCD" ]; then echo "WARNING: Before running remastersys unmount" echo "all network shares and close ALL windows." echo "" read -p "When ready, press enter to continue..." nothing echo "Making backup directory, and cleaning remasterys..." sleep 2s sudo mkdir $INCREMENTS sudo remastersys clean echo "Running rsync backup..." sleep 2s sudo rsync -acb --progress --exclude-from="$EXCLUDES" --backup-dir=$INCREMENTS $SOURCEDIR $BACKUPDIR echo "Running remastersys...." sleep 2s sudo remastersys dist crunchbang_deskspin_$BACKUPTIME.iso echo "Copying livecd iso to backup..." sleep 2s sudo cp $SOURCEISO $BACKUPISOS sudo remastersys clean echo "Super backup on $BACKUPTIME complete." echo "Thank you for your diligence." else if [ "$type" = "Cancel" ]; then echo "Script works, but you have not backed up. Lazy..." fi fi fi #end
Last edited by jmbarnes (2010-05-10 21:51:31)
Question: once you create a backup, how do you restore it?
BTW if you wish to contact me, send me an e-mail instead of a PM.
what are the benefits over Remastersys?
Xmonad is the best way to get things done, fast.
My french linux blog: http://cbrunos.wordpress.com
@anonymous: Luckily at this point I haven't had to do a full out restore. What I have done is used the LiveCD's to transplant my setup and I've used the backup increments to find a number of files I stupidly deleted. Personally I use it only to back up my home directory. I would imagine if / when the full restore is necessary I'll install the base via the LiveCD and copy over /home.
@cbrunos: First, for the liveCD creation it does use remastersys. I assume you are asking why I don't use remastersys' backup mode? As far as I am aware, the backup mode is unable to make incremental backups and put the changes since previous in a dated file. Second, in my use of backup mode it takes a long time. Most often I'm simply running the "normal" backup option, only once ever few weeks to I generate a LiveCD.