Beginner: Full Linux Server Backup


This has been tested with a working server of Debian5.

Login as root

Make a backup directory. It is best if you have the backup directory on another partition or another hard disk

mkdir -p /backup

Create a backup sh file with arguments to backup the whole system while excluding contents of proc sys dev and backup directory

vi /backup/backup.sh

tar -cvpf /backup/fullbackup.tar –directory=/ –exclude=proc –exclude=sys –exclude=dev/pts –exclude=backup .

Create a restore sh file which moves the fullbackup.tar file to / and then extracts it

vi /backup/restore.sh

mv /backup/fullbackup.tar /fullbackup.tar

tar -xvpf /fullbackup.tar

Change the file permissions to make it executable

chmod -R 750 /backup

Add an argument to crontab to make it run at 22:10 daily.

crontab -e

10 22 * * * /backup/backup.sh

Done!

To restore this backup, install a minimal version of the same linux flavor and then run /backup/restore.sh

Gulshan Yashveer Beejan

Gulshan holds a BSc(Hons) Computer Science with Distributed systems from the City University of London. He is currently working at DSOGroup(Mauritius) as a Linux Administrator on SaaS Solutions. More about Gulshan

Leave a Reply

Your email address will not be published. Required fields are marked *