Back to Browse

How to perform Rsync remote backups on Linux

212 views
Dec 23, 2023
15:21

Commands - Change password: passwd root Change permissions: chmod 600 ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa.pub Rsync Backup Script - # Local machine details (Computer 1) local_source_dir="/home/rahrah_studios/Downloads/ForYouTube" local_private_key="~/.ssh/id_rsa" # This is required for private/public key authentication # Global variable for both local and remote contexts backup_dir="incremental_backups" # Remote machine details (Computer 2) remote_username="root" # This is the remote user you are connecting to remote_host="192.168.1.184" # This is the ip address (local or public) of the remote computer remote_port="2525" # This is the port for your ssh connection remote_backup_base="/media/backups" # This should be the path on Computer2 # Format the current date current_date=$(date +"%Y%m%d") # Construct the remote destination path with the current date remote_destination_path="${remote_backup_base}/${backup_dir}/${current_date}" # Rsync command with incremental backup from local to remote rsync -av --backup --backup-dir="${remote_destination_path}" --link-dest="${remote_backup_base}/current" -e "ssh -i ${local_private_key} -p ${remote_port}" "${local_source_dir}" "${remote_username}@${remote_host}:${remote_destination_path}/" # Update the symlink to the latest backup on the remote host (provided for ease of access) ssh -i "${local_private_key}" -p "${remote_port}" "${remote_username}@${remote_host}" "ln -sfn ${remote_destination_path} ${remote_backup_base}/current"

Download

0 formats

No download links available.

How to perform Rsync remote backups on Linux | NatokHD