rss feed Twitter Page Facebook Page Github Page Stack Over Flow Page

Setup Backup

Every system should have backups. In case of emergency, backup are very useful. Your backup can save you hours of downtime with a minimum impact.

There's is some tools you can use to back up your entire system or your most important files. tar, gzip, bzip2, dump and rsync are some tools you can use to back up files and folders. automysqlbackup is a tool to backup your MySQL databases.

Example backup

Here's an example of a folder backup including all the sub-folders and files within.

tar -cvf archive-name.tar dir1 dir2 dir3....

Now, let's compress it:

gzip -9 archive-name.tar

You can use bzip2 instead. bzip2 has a better compression rate but is a little slower.

To combine both command, you can use the -z option.


dump is written specifically for backups. It backs up the entire file system and allows multiple levels of backups. The corresponding restore command allows for restore from a dump backup.

For example, to back up /boot file system:

dump 0zf backup.boot /boot

Backup MySQL

There's an easy command to back up MySQL databases. automysqlbackup can automatically make daily, weekly, and monthly backups of your MySQL database.


sudo aptitude install automysqlbackup

Configure Backup

sudo vi /etc/default/automysqlbackup

All the backup are stored in the /var/lib/automysqlbackup by default. It is recommended to change this folder. To change the default backup folder, edit the file and modify the BACKUPDIR= to the new location.

You can also receive an email if there's an error while running the backup. To do this, you need to change the MAILADDR= and add your email address.

Backup Home Folder

You can back up your entire home folder using the zip command. If you want to exclude some folder, you need to use the --exclude parameter.

zip -r  * --exclude=access_log --exclude=public_ftp --exclude=tmp