Menu
![Script Script](/uploads/1/2/5/6/125624859/715461617.jpg)
I´m trying to make a script that ssh to multiple server and run a backup of them. The server has different folders that should be included.I´m trying to do this with 2 files one that specify the hostname and the folders that should be included in the backup. SERVERHOST=server1SOURCE='/home'SOURCE='/etc'SERVERHOST=server2SOURCE=/home'SOURCE='/etc'SOURCE='/var'EOFAnd one file that reads from this file and execute the backup. While read hostdofor i inrsync -chazP -fake-super -rsync-path='sudo rsync' -stats backup@$host:/home /var/backup/$host/donedone.
![Rsync Backup Script Rsync Backup Script](/uploads/1/2/5/6/125624859/211131927.png)
Anyway, in the first post of the shell scripts series, let me introduce you to my Rsync based local backup solution. Configuration File This script reads a configuration file named ‘rsyncbackup.config’ and backups all the folders specified in that file to another location in the same system. Now we can use scp or rsync to transfer data from host A to host B without password required. V.) Modify /etc/crontab file to schedule the execution of backup script. Add this line to the end of the crontab file: 0 2. root bash backup.sh # the script file backup.sh is scheduled to be executed every day at 2:00AM.
# This command is included by do-remote-backup.bsh to set parameters.BACKUPNAME='nametosaveasinbup'# Backup set (array of root folders we backupBACKUPSET=( 'directories' 'tobackup' 'in' 'the' 'root' 'directory' )BACKUPROOT='/cygdrive/c'# Backup destination settingsREMOTEUSER='backup'REMOTEHOST='backup-server'REMOTEROOT='backup'REMOTETARSTORAGE='.' # File-transfer retry settingsMAXRETRIES=10# Email SettingsMAILTO=('[email protected]')SMTPSERVER='smtp.gmail.com'SMTPPORT='587'SMTPFROM='[email protected]'SMTPUSER='host account'SMTPPASSWORD='host account password'# minimum time between sending notification emails of backups completed (in seconds)# 43200 = 12 hoursMAILFREQUENCY=43200# skip doing tar archive creation for failed snapshots (not recommended!)SKIPRECOVERY=1.