|
@@ -1,12 +1,16 @@
|
|
|
# Remote Backup Manager
|
|
|
-This script uses rsync to backup files from any source (e.g. Remote) to any target (usually the host, the script runs on). Once the
|
|
|
+This script uses rsync to backup files from any source (e.g. Remote) to any target (usually the host, the script runs on). On completion (either successful or on error), the scripts sends a mail with the output of rsync to a specified mail address.
|
|
|
|
|
|
## Dependencies
|
|
|
sendmail needs to be installed and configured for sending backup notifications.
|
|
|
|
|
|
## Installation
|
|
|
-Pull the repository to a location of your choice on the host.
|
|
|
-Configure your ssh client, such that rsync neither requires passwords, ports, etc. Use the ```config``` file under your ```.ssh``` folder.
|
|
|
+Pull the repository to a location of your choice on the host.
|
|
|
+
|
|
|
+## Configuration
|
|
|
+Configure your ssh client for all remote source or target directories specified in your configuration,
|
|
|
+such that rsync neither requires passwords, ports, etc. Use the ```config``` file under your ```.ssh``` folder.
|
|
|
+An example configuration for a host is given as follows.
|
|
|
```
|
|
|
Host sebastianvendt.de
|
|
|
HostName sebastianvendt.de
|
|
@@ -14,16 +18,35 @@ Host sebastianvendt.de
|
|
|
IdentityFile /home/sebastian/sshKeys/rsyncOnSebastianvendt.de.pem
|
|
|
```
|
|
|
|
|
|
+Create a configuration file, which holds the source and destination paths for the backup jobs as well as several configuration variables.
|
|
|
+An example configuration file with all *required* variables is given in the following.
|
|
|
+```
|
|
|
+#Backup directories
|
|
|
+declare -A backup_folders
|
|
|
+backup_folders["backupuser@hostA.com:/opt/SourceFolderA"]="opt/backup/folderA"
|
|
|
+backup_folders["/opt/SourceFolderB"]="opt/backup/folderB"
|
|
|
+
|
|
|
+#Configuration
|
|
|
+logPath=/home/user/logs/backupjob/
|
|
|
+logFileName="$(date +'%Y-%m-%d_%H-%M')_backupjobs.log"
|
|
|
+tmpLogFilePath=/tmp/tmp_backup.log
|
|
|
+retryAttempts=2
|
|
|
+mailFrom="backup@backupserver.com"
|
|
|
+mailTo="user@domain.com"
|
|
|
+
|
|
|
+#Delete logs older than rotationDays
|
|
|
+rotationDays=14
|
|
|
+```
|
|
|
+
|
|
|
## How to run the script
|
|
|
-Create a configuration file, which holds the source and destination paths. An example configuration file is given in the following. Please note, this is also a shell script and it also must be executable!
|
|
|
+The script requires as argument the path to the configuration file
|
|
|
```
|
|
|
-#!/bin/bash
|
|
|
-declare -A backup_folders #Do not change this name
|
|
|
-backup_folders["rsync@sebastianvendt.de:/var/lib/psa/dumps/domains/sebastianvendt.de/"]="/home/sebastian/ARCHIVE/sebastian/3000_BACKUP/sebastianvendt.de/configuration"
|
|
|
-backup_folders["backup@serles.local:/var/lib/openhab/backup"]="/home/sebastian/ARCHIVE/sebastian/3000_BACKUP/serles.local/backup"
|
|
|
+/path/of/script/getRemoteBackup.sh /path/to/configuration
|
|
|
```
|
|
|
|
|
|
-Add the script with the path to your configuration file to your crontab-file. I suggest to run it in a screen. You can then always reattach to the screen and check the current status for long backup jobs.
|
|
|
+## Automate the backup job
|
|
|
+To automate your backup, add the script with the path to your configuration file to your crontab-file. I suggest to run it in a detached screen session.
|
|
|
+You can then always reattach to the screen and check the current status for long backup jobs.
|
|
|
```
|
|
|
10 2 * * * sebastian screen -d -m /home/sebastian/scripts/backup/getRemoteBackup.sh /home/sebastian/scripts/backup/backupFolders.conf
|
|
|
```
|