Skip to content

Instantly share code, notes, and snippets.

@mufus
Last active January 24, 2019 07:46
Show Gist options
  • Save mufus/51cd2330ad86b4dc18f2 to your computer and use it in GitHub Desktop.
Save mufus/51cd2330ad86b4dc18f2 to your computer and use it in GitHub Desktop.
Rsnapshot with sudo

Generate ssh-keys

ssh-keygen

Hosts to back up

root@web02:~# apt-get install sudo
root@web02:~# useradd backupuser -c "limited backup user" -m
root@web02:~# mkdir /home/backupuser/.ssh
root@web02:~# vi /home/backupuser/.ssh/authorized_keys
root@web02:~# vi /home/backupuser/rsync-wrapper.sh
#!/bin/sh
date >> /home/backupuser/backuplog
echo $@ >> /home/backupuser/backuplog
/usr/bin/sudo /usr/bin/rsync "$@";
root@web02:~# chown -R backupuser:backupuser /home/backupuser/
root@web02:~# chmod 755 /home/backupuser/rsync-wrapper.sh
root@web02:~# chmod 700 /home/backupuser/.ssh
root@web02:~# chmod 600 /home/backupuser/.ssh/authorized_keys
root@web02:~# visudo
backupuser ALL=NOPASSWD: /usr/bin/rsync

Backup-server

root@storage:~# vi /etc/rsnapshot.conf
rsync_long_args --delete --numeric-ids --relative --delete-excluded --rsync-path=/home/backupuser/rsync-wrapper.sh
ssh_args        -c blowfish -i /root/.ssh/id_rsa.backupuser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment