CtrlK

Fundamentals

Backups

Backup using rsync

Backup a local Directory to our Backup-Server

rsync -av /path/to/mydirectory user@backup_server:/path/to/backup/directory
-a: archive: preserve the original file attributes
-v: verbose

rsync -avz --backup --backup-dir=/path/to/backup/folder --delete /path/to/mydirectory user@backup_server:/path/to/backup/directory

backing up the mydirectory to the remote backup_server, preserving the original file attributes and enabled compression (-z) for faster transfers.
--backup option creates incremental backups in the directory /path/to/backup/folder,
--delete option removes files from the remote host that is no longer present in the source directory.

Restoring backup

rsync -av user@remote_host:/path/to/backup/directory /path/to/mydirectory

Encryption

rsync -avz -e ssh /path/to/mydirectory user@backup_server:/path/to/backup/directory

Auto synchronise with cron

• Generate ssh keys first
ssh-keygen -t rsa -b 2048
• Transfer it to remote sytem
ssh-copy-id user@backup_server
• Create script that automates the backup
#!bin/bash
rsync -avz -e ssh /path/to/mydirectory user@backup_server:/path/to/backup/directory
• give execute permission and open crontab -e and add the backup file
0 * * * * /path/to/RSYNC_Backup.sh