Tutorial: Linux and UNIX ssh, rsync, and tar

Опубликовано: 26 Март 2026
на канале: The Expat Professor
423
like

Create your Keys
ssh-keygen

Verify Connectivity
ping 192.168.56.100
nmap -p22 192.168.56.100

Install SSH on the backup host if required
apt-get install ssh

Copy your public key to authorized_keys on the backup server
ssh-copy-id -i /home/ppoteete/.ssh/id_rsa.pub [email protected]

Verify that you can remotely connect without a password (exit after verification)
ssh [email protected]

Create a backup destination on the backup server from your workstation
ssh [email protected] 'sudo mkdir /home/backups'
ssh [email protected] 'sudo chown admin-backup.admin-backup /home/backups -R'


Perform a backup to the remote system
rsync -zurl /tmp/Security [email protected]:/home/backups/

Script the backup for remote tar procedures
vi backup.sh
#!/bin/bash
echo "Syncing..."
rsync -zurl --delete /tmp/Security [email protected]:/home/backups/

echo "Running Backup..."
ssh [email protected] 'tar czf /home/backups/`date +%Y%m%d%H%M`-Security.tar.gz /home/backups/Security/'

echo "Process Complete"
ssh [email protected] 'ls -lh /home/backups'

Assign Permissions to the script
chmod 775 backup.sh

Run the script
./backup.sh

Please join me:
   / paulwpoteete  
  / paulwpoteete  
  / paulwpoteete