Thursday, December 31, 2009

NEVER automount your backup directories

NEVER automount your backup directories
the infamous "rm -rf /" will erase your automounted backups too


Always mount the backup directory before performing backups
Always unmount the backup directory when done performing backups


Prune your backups of un-necessary files from being backed up
tar --exclude /tmp --exclude /proc ...
egrep ".netscape/cache| *.o | *.swp | *~ | ..."


Be sure that the backup files is NOT group/world writable/readable
It'd contain confidential data, passwds etc


chown root /Backup_Dir/Date.x.tgz
chgrp backup /Backup_Dir/Date.x.tgz
chmod 440 /Backup_Dir/Date.x.tgz


encrypt your backup files if you are really paranoid about your passwd files




Example Backup Commands
Creating datestamps for file names
date '+%Y%m%d'
Ouputs 20020615 for June 15, 2002


date '+%Y.%m.%d'
Ouputs 2002.06.15 for June 15, 2002

www.thing.dyndns.org bash examples


dd -- copying partitions, mirror'd partitions
mounting and unmounting is NOT needed in this case
dd if=/dev/hda1 of=/dev/hdb1 bs=1024


Simplified tar --newer Incremental Backup example
LastBackupTime = `cat /Backup_Dir/Last.txt`
tar zcvf --newer $LastBackupTime /Backup_Dir/Date.x.tgz $DIRS
echo "Date" > /Backup_Dir/Last.txt


Simplified find | tar Incremental Backup example
Cnt = `cat /Backup_Dir/Last.txt`
find $DIRS -mtime -$Cnt -print | tar zcvf /Backup_Dir/Date.$Cnt.tgz -T -
echo "$Cnt +1" > /Backup_Dir/Last.txt


Simplified dump | restore Backup example


Simplified cpio Backup example
find /home -xdev | cpio -pm /mnt/backup

1 comment: