Directories to backup is dictated by the partitions used in your Server.
Usually it is user data - /root, /etc, /home, /usr/local
Optionally backup log files and pending emails
/var/log, /var/spool/mail
What is the Backup Media ?
Backups should be on a different server or a Storage Device than the server/data you are trying to backup.
NEVER backup your data to the same partition, nor same disk
Different Scenarios of Backup :
Copying From one Harddisk to another on Same Server :
Type - 1
dd if=/dev/hda1 of=/dev/hdb1 bs=1024k
Incase the hda1 Fails, you can remove hda1 and boot with hdb1 as primary.
Type - 2
Copying /home on /dev/hda1 to a /dev/hdb1 ( backup disk )
#mount /dev/hdb1 /mnt/backup
#( tar cf - /home ) | ( cd /mnt/backup ; tar xvfp - )
#umount /mnt/backup
Type - 3
scp Copying /home on /dev/hda1 to a /dev/hdb1 ( backup disk )
#mount /dev/hdb1 /mnt/backup
# scp -par /home /mnt/backup
# umount /mnt/backup
Type - 4 ( Consumes Good amount of memory )
find | cpio Copying /home on /dev/hda1 to a /dev/hdb1 ( backup disk )
#mount /dev/hdb1 /mnt/backup
#find /home -print | cpio -pm /mnt/backup
#umount /mnt/backup
To View Contents :
cpio -it < file.cpio
To Extract a file :
cpio -id "usr/share/file/doc/*" < file.cpio
Note : In the above examples /mnt/backup is in hda1
Examples of Incremental Backup script if planning to scp to a different server :
For Creating Date Stamps ---- date '+%Y%m%d'.tar.gz
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
- 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