Server backup against misfortune
Now it is time to add some extra protection by installing a good server backup software. VestaCP has its own daily server backup service. It is good enough, but backup files are still on your server hard disk. Moreover VestaCP does not backup Linux files and software configurations.
What I suggest is to send periodically backup files to an external FTP server. Just send modified or new files, removing the old ones. If you do not want to set up another server just to have an FTP account, you can install FileZilla server on a computer (it should be always switched on).
Mondorescue is a server backup utility that allows you to add server protection, by backing up your server to CD, to DVD or to hard disk ISO file. In the event of data loss, you will be able to restore all of your data [or choose what to restore], also from bare metal if necessary.
To install Mondorescue on CentOS (32 bit), use ExtraPutty to access your server via SSH and follow this procedure:
yum install mondo
To install Mondorescue on CentOS (64 bit), use ExtraPutty to access your server via SSH and follow this procedure:
yum install mondo
Starting a server backup
Access your server using ExtraPutty and run mondoarchive.
A welcome screen will appear: “W E L C O M E T O M O N D O R E S C U E“
Now, answer as below:
Please choose the backup media to which you want to archive data:
Please enter the full path name to the directory for your ISO images:
Please specify the type of compression that you want:
bzip2 (of course you can change it)
Please specify the level of compression that you want:
Please enter how big you want each ISO image to be (in megabytes):
Do not change the default value (4480)
Please enter the prefix that will be prepended to your ISO filename:
backup-yyyy-mm-dd (you can type another name, but I suggest to include date in this format: year-month-day)
Please enter paths (separated by ‘|’) which you want me to backup:
Do not change the default value (/ = full backup)
Please enter paths which you do NOT want to backup. Separate them with ‘|’:
/backup|/home/backup (please do not add your previous backup to this one!)
Please enter your temporary directory:
Do not change the default value
Please enter your scratch directory:
Do not change the default value
Do you want to backup extended attributes?
Will you want to verify your backups after Mondo has created them?
Are you confident that your kernel is a sane, sensible, standard Linux kernel?
Are you sure you want to proceed?
You may need up to 2 hours to back up your server.
The ISO file containing your server backup will be created in the /home/backup folder. You can access it and download using WinSCP. If you want to automatically transfer backup files to an FTP server, use LFTP (see below).
Restore your data
Access your server using ExtraPutty and run mondorestore.
You can choose what to restore (full server backup or some data).
LFTP (sophisticated file transfer program)
VestaCP automatically performs a daily backup of websites, mails, databases, DNS, and accounts. You can set how many backups you want to store for each user (in the admin account). Backup files are in /home/backup folder. You may perform a mondoarchive server backup, writing the ISO file in the same folder.
Unfortunately, this folder is on the same hard disk of your data. A failure of the hard disk will however result in data lost. It is important to send backup files to another hard disk or media.
My idea is to automatically send all backup files to a FTP server, located on another computer or network hard disk. LFTP can automatically mirror a folder, so that you can have the exact copy of your backup folder on another storage. To reduce bandwidth, just new and modified files are transferred. Deleted files will be removed from the mirror folder too.
To install LFTP on CentOS, use ExtraPutty to access your server via SSH and run:
yum install lftp
Creating file transfer scripts
Now we will create a script file to automate file mirroring of /home/backup folder to an exernal FTP server.
Use WinSCP and create a new file in /home/backup folder, naming it ftpbackup.
Edit /home/backup/ftpbackup file and add the following text:
open -u user_name,password -p 21 ftp://ftp_address/
mirror -c -e -R /home/backup / –log=/home/backup/ftpbackup.log
Replace user_name, password and ftp_address with proper values. 21 is the FTP port.
Manually start the transfer script
lftp -f /home/backup/ftpbackup
Setting CRON to automatically start LFTP
Using WinSCP, create a new file /etc/cron.d/ftpbackup, containing:
# /home/backup to FTP
25 5 * * * root /usr/bin/lftp -f /home/backup/ftpbackup
Where 25 are minutes and 5 are hours. In the example above, LFTP is starting at 5.25 AM (some minutes after VestaCP automatic backup).
Now, restart cron using ExtraPutty: service crond restart
To retrieve the list of FTP remote files, use ExtraPutty and type:
> open -u user_name,password -p 21 ftp://ftp_address/
Replace user_name, password and ftp_address with proper values.