|
||||||||||
|
Automatic backups to the backup-FTP from StratoAll data that really matters to you should be backed-up frequently. If the server is from the german hoster Strato the available FTP-Server is the best way to go. SecurityThe username, password and hostname can be fetched from the website where the server configuration is done as soon as the backup server is configured. The access to this server from outside the Strato data center, it has to be done from the root-server. The username and password used for login should be secure enough with this restriction, but automatic backups are the prefered way these have to be stored somewhere on the server. So if the server is compromised, the password and username for the backup-FTP are compromised too. The backups should be checked if something like that happened. The Tools
These tools are bind together with a little script. This can be done with the in the base install included Korn Shell. PrerequesitesFirst the access to the backup-FTP server should be automated. For this the following entry into the file .netrc (in the home directory of the user doing the backup) must be made:
With USER and SECRET replaced with the login information that were given by Strato. The login to that server should happen automated from now on. A directory must be created on the backup-FTP. For simplicity I have named it backup. The script has to be edited if another directory is chosen. In the next step the filenames, that are to be backed-up are written to a file. For each slice on the server a new file must be used because dump can not work on several filesystems. These files are stored in /root/data. The names for the files are chosen from the mount points of the filesystems: backup-root for /; backup-home for /home, etc. As an example the first lines of my backup-root:
With these entries the home directory from root and the files boot.conf and fstab inside the directory /etc are marked for backup. The following script builds from these entries an argumentlist for dump. dump makes a backup of these files into a temporary file. This file is removed after the transfer finished. The Script
From the actual date a filename for the backup is generated. To spare as much space as possible on the server the files are piped through gzip. After the file was transfered to the server the script checks for a backup file that is 30 days older is on the server. Actually there is no check, the script attempts to remove the file from the server. Does no such file exist the server will output an error message which has no effect on the further execution of the script. Unfortunately I did not manage to pipe the output from dump to the ftp client. Therefor enough space has to be available in /tmp or another way using temporary files would have to be implemented. If someone works out a better solution I would like to use it here. verwenden. At Regular Intervals?If the script is to be started on a daily basis only an entry in the crontab from root is missing. Aware: HOME=/root was added to the to override the default /var/log. If this is not done the .netrc from roots home directory can not be used. The necessary crontab entry looks somehow like this:
Every morning at 4:45 am a backup would be started and transfered to the ftp server. |