Configuring Backups

Version Date Notes By
0.2 2019-06-11 Added: Reconfiguring in case of loss of configuration jfm
0.1 2018-06-19 Initial release jfm

Reconfiguring in case of loss of configuration

Adding a new Backup

Sincronizing remote backups

Currenty there are 2 server that sincronize remote backups:

Configuring Lenovo NAS

  1. Create a new bash script in /nfs/rsync/scripts/ containing the script to rsync the remote data. You can use this template:
#!/bin/sh
SSH_CMD="ssh -p<remote_ssh_port>"
EXCLUDE=/mnt/pools/A/A0/rsync/conf/rsync_<server_name>.excludes
FROM=<remote_user>@<remote_ip_address>:<folder_to_backup>
TO=/nfs/Backups/<backup_destination_folder>
OPTS="-arvz --stats --human-readable"
NOW=`date +%Y%m%d_%H%M`

LOG=/mnt/pools/A/A0/rsync/logs/rsync_<server_name>_$NOW.log

rsync $OPTS -e "$SSH_CMD" --exclude-from=$EXCLUDE $FROM $TO > $LOG

Example:

#!/bin/sh
SSH_CMD="ssh -p1022"
EXCLUDE=/mnt/pools/A/A0/rsync/conf/rsync_linode_webapps.excludes
FROM=devel@172.104.235.164:/backups/
TO=/nfs/Backups/linode_webapps/
OPTS="-arvz --stats --human-readable"
NOW=`date +%Y%m%d_%H%M`

LOG=/mnt/pools/A/A0/rsync/logs/rsync_linode_webapps_$NOW.log

rsync $OPTS -e "$SSH_CMD" --exclude-from=$EXCLUDE $FROM $TO > $LOG
  1. Copy the public key in /.ssh/ id_rsa.pub to the ~/.ssh/authorized_keys file on the remote server

  2. Check if you can access the server: ssh -p<port> <remote_user>@<remote_ip>

  3. Test if the bash script runs without any problems

  4. If everything is OK Add a cronjob for the new script

Reconfiguring in case of loss of configuration

When the NAS is rebooted it cleans (default restore) some configuration files including /.ssh folder and crontab entries, so we have to restore the backup configuration.

  1. Copy the content of the file /nfs/rsync/conf/crontab to crontab (run: crontab -e)
  2. Copy the folder /nfs/Backups/NAS/conf/ssh to /.ssh: cp -R /nfs/Backups/NAS/conf/ssh /.ssh
  3. Check if everything is OK by running /nfs/rsync/scripts/sshTest.sh, the result should be:
LinodeRAR devel@178.79.186.17: OK
LinodeGitlab devel@176.58.119.40: OK
LinodeClientes devel@212.71.237.118: OK
Wazuh wesec@212.111.43.62: OK
LinodeWebApps devel@172.104.235.164: OK

If you get errors, you probably have to try to login manualy to accept the authenticity of the host, then run the test again

Found errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to make your changes.