We all know that backing up your data is one of the most important jobs for any admin. With Linux, we can also easily backup our configurations for our servers, since all configs are just files.
What I do is create a folder under /var/, called server_backup:
sudo mkdir /var/server_backup
Whenever I edit a config or have any data that should be backed up, I make a symlink to it in /var/server_backup, recreating the full path from root, starting at /var/server_backup. For example, if I had a Samba server, I would want to back up the config, as well as the files themselves, which we are going to assume I placed in /srv/files. Now, to add these to my backup, I would simply do this:
sudo mkdir -p /var/server_backup/etc/samba
sudo ln -s /etc/samba/smb.conf /var/server_backup/etc/samba/
sudo mkdir -p /var/server_backup/srv
sudo ln -s /srv/files /var/server_backup/srv/
If you have files that only exist as backups (i.e. SQL dumps, etc), just dump them right into /var/server_backup/backup. You can even create a server_info.txt file under /var/server_backup that contains any important information for that server.
Now we have all the important config/data/etc for that server in one neat folder. This has an added benefit of being an easy way to navigate to anything important on that server. i.e. "where was the config that strange package located?"
To backup the server, all we have to do now is create a simple cron job to rsync it to our backup. For this example, I will just be backing it up to an external hard drive, but in real life, it would be best to back it up to one central backup server, which would have some sort of removable media that it backs up all servers to.
sudo crontab -e
add the following line (changing to your needs):
0 30 * * * rsync -avLE --delete /var/server-backup /media/backup
That will run the rsync every night at 12:30 am. Easy, right?
No comments:
Post a Comment