Most of us have experienced the loss of valuable files and data at some point in time when a local storage system fails. We know the importance of backing up our files and data, but few have implemented a proper backup solution.
Good backup strategies include creating a consistent and automatic backup and storing the backup in a remote location.
Automated remote backup in Linux could be implemented by automating rsync to back up to a remote SSH server.
Related: How to SSH without password
remoteuser@remoteserver:$ mkdir -p ~/backup_folder/folder_01
remoteuser@remoteserver:$ chmod -R 777 ~/backup_folder/folder_01
localuser@localhost:$ rsync -av --delete /path/to/folder_01/ remoteuser@remoteserver:backup_folder/folder_01
Sample of a more complete script for automated backup.
#!/bin/bash TARGET="remoteuser@remoteserver:~/backup_folder" for i in folder_01 folder_02 folder_03; do rsync -av --delete $i/ $TARGET/$i; done
remoteuser@remoteserver:$ ls -l ~/backup_folder/folder_01
localuser@localhost:$ crontab -e
# Run backup command every day on midnight, sending the logs to a file. 0 0 * * * rsync -av --delete /path/to/folder_01/ remoteuser@remoteserver:backup_folder/folder_01 >>~/.backup.log 2>&1
Related: Crontab Generator
Comment anonymously. Login not required.