backup script example of a server

source : debian-user-digest # 1283.

[ A ] : 1.) GZIP's everything but: proc, sys and others,
2.) signs said backup and then encrypts it and
3.) an SSH cert to the other server and the time to make said simple script.
You can even use Perl or PHP, both of which support being daemonized so you can do incremental backups or backups of specific files based on changes.

#!/bin/bash -e

echo $(date): [Info] Starting backup of server_name >> /var/log/backups.log
tar cvpjf server_backup.tar.bz2 --same-owner \
--exclude=/proc/* \
--exclude=/media/* \
--exclude=/dev/* \
--exclude=/mnt/* \
--exclude=/sys/* \
--exclude=/tmp/* \
--exclude=/usr/tmp/* \
--exclude=/lost+found/* \
--exclude=/server_backup.tar.bz2

You'll of course want to remove server_backup.tar.bz2, generate a certificate to sign and encrypt and move that certificate to your personal PC too and make more log entries throughout the process so you can diagnose a missed backup, but other than that it's pretty simple.


[ B ] : my clients need verbose lists of files that were backed up in certain places and we grep that out for their automatic emails.

In case the OP wants to know what we're on about, and so we don't stray to far off topic here is an example of piping tar to SSH :

#!/bin/bash -e

echo $(date): [Info] Starting backup of server_name >> /var/log/backups.log
tar cvpjf server_backup.tar.bz2 --same-owner \
--exclude=/proc/* \
--exclude=/media/* \
--exclude=/dev/* \
--exclude=/mnt/* \
--exclude=/sys/* \
--exclude=/tmp/* \
--exclude=/usr/tmp/* \
--exclude=/lost+found/* \
--exclude=/server_backup.tar.bz2 | ssh client_operator@backup.domain.com "dd of=server_backup.tar.bz2"
 
 
Creative Commons License
This work by maniac.vardhan is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
 
 

0 comments :: backup script example of a server

Post a Comment