Offline Backup: RSYNC to ServerA from ServerB
Summary
Do offline backup from copying backup medias to another Server
How-to
1. On ServerA
2. On ServerB
Copy the public key to ServerA
OR
3. On ServerA
Create ~/.ssh/authorized_keys if not have
Edit /etc/ssh/sshd_config
4. On ServerB
# 7am Daily
/etc/crontab:
Update
Do offline backup from copying backup medias to another Server
How-to
1. On ServerA
# useradd BACKUP-SRV
# passwd BACKUP-SRV
# passwd BACKUP-SRV
2. On ServerB
# Private Key: ~/.ssh/id_rsa
# Public Key: ~/.ssh/id_rsa.pub
#
#@ref https://en.wikipedia.org/wiki/Key_size#Asymmetric_algorithm_key_lengths
# ssh-keygen -b 4096 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/APP-SRV/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/APP-SRV/.ssh/id_rsa.
Your public key has been saved in /home/APP-SRV/.ssh/id_rsa.pub.
The key fingerprint is: {KEY}
The key's randomart image is:
+--[ RSA 4096]----+
| |
| [.........] |
| |
+-----------------+
# Public Key: ~/.ssh/id_rsa.pub
#
#@ref https://en.wikipedia.org/wiki/Key_size#Asymmetric_algorithm_key_lengths
# ssh-keygen -b 4096 -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/APP-SRV/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/APP-SRV/.ssh/id_rsa.
Your public key has been saved in /home/APP-SRV/.ssh/id_rsa.pub.
The key fingerprint is: {KEY}
The key's randomart image is:
+--[ RSA 4096]----+
| |
| [.........] |
| |
+-----------------+
Copy the public key to ServerA
# scp ~/.ssh/id_rsa.pub BACKUP-SRV@ServerA:
OR
# scp ~/.ssh/id_rsa.pub BACKUP-SRV@ServerA:~/.ssh/authorized_keys
3. On ServerA
Create ~/.ssh/authorized_keys if not have
# touch ~/.ssh/authorized_keys
# cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
# rm ~/id_rsa.pub
# rm ~/id_rsa.pub
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Edit /etc/ssh/sshd_config
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
AllowUsers BACKUP-SRV@ServerB
AuthorizedKeysFile .ssh/authorized_keys
AllowUsers BACKUP-SRV@ServerB
4. On ServerB
# 7am Daily
/etc/crontab:
0 7 * * * UserA rsync -avz -e "ssh -p22" --del /home/APP-SRV/backup/ BACKUP-SRV@ServerA:/store/APP-SRV-Backup/ > /dev/null 2>&1
Update