LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   system backup script (https://www.linuxquestions.org/questions/linux-software-2/system-backup-script-859521/)

DebianUser 01-30-2011 03:34 AM

system backup script
 
I currently backup my user home directories on an ad-hoc basis but i'd like to also have a system backup in case everything breaks.

Is there software that can do this via CLI or a bash script that would do the same thing? i'd like to exclude the /home folder and basically backup anything else ie programme conf files etc.

barriehie 01-30-2011 09:53 AM

Quote:

Originally Posted by DebianUser (Post 4242156)
I currently backup my user home directories on an ad-hoc basis but i'd like to also have a system backup in case everything breaks.

Is there software that can do this via CLI or a bash script that would do the same thing? i'd like to exclude the /home folder and basically backup anything else ie programme conf files etc.

I use rsync to backup my machine every day via /etc/crontab. I'm using a homemade bash script and backing up /home to one dir. and everything else to another dir. There are packages that can backup; search your package manager.

DebianUser 01-31-2011 09:55 AM

which directories do you exclude? I assume proc dev tmp any more? Also how does this work with packages installed via apt will they still work after a restore?

barriehie 01-31-2011 10:48 AM

Quote:

Originally Posted by DebianUser (Post 4243538)
which directories do you exclude? I assume proc dev tmp any more? Also how does this work with packages installed via apt will they still work after a restore?

My command to backup everything is like this:
Code:

rsync -av --exclude-from=/usr/local/bin/eList  / /media/backup/$dow && touch -m -t $(date +%m%d)06$dom /media/backup/$dow
As you can see it makes a dir. that has the name of the day of the week. I'm using an external 80 Gig drive so I just let those keep writing over the last weeks backups. I'm then touching the file so that the mod time is 06 hours and day of the month minutes. Prior to backing up my home dir I do a bit of cleanup that is the majority of the script, removing old session files, thumbnails, etc.

The file list of excluded dir.'s is this:
Code:

tmp/
proc/
lost+found/
mnt/
sys/
media/
dev/

In regards to everything working after a restore it did the last time I 'oopsed' and had to use my backup. Excluding the down time, about 30 min., you would've never known anything had broken.

HTH

DebianUser 01-31-2011 01:24 PM

thanks for the info, i've just a test run using tar and all seemed ok, I take it a restore would be as simple as untaring at /? how do you restore if using the rsync method?

barriehie 01-31-2011 02:38 PM

Quote:

Originally Posted by DebianUser (Post 4243745)
thanks for the info, i've just a test run using tar and all seemed ok, I take it a restore would be as simple as untaring at /? how do you restore if using the rsync method?

Been awhile since I've used tar so can't help there but using rsync would be a matter of reversing your original source and destinations. I used to use tar with gzip but it took entirely TOO LONG to retrieve a specific file.

szboardstretcher 01-31-2011 02:51 PM

If you have time in your schedule to shut the machine down, unmount the partitions,.. you can do a 1:1 image copy using partimage...

barriehie 02-01-2011 12:06 AM

In my prior post I've neglected how I defined $dow and $dom...
Code:

dow=$(date +%w) # Day No. Of Week; e.g. 0=Sunday, 1=Monday, 2=Tuesday, etc.
dom=$(date +%d) # Day No. Of the Month; e.g. [0-31]



All times are GMT -5. The time now is 05:20 AM.