Keeping a directory automatically backed up somewhere is always useful. Every few months this is needed on one machine or another. Here are the steps:
- First set up ssh keys so passwords are no longer needed.
- Test things by verifying a ‘ssh user@yourserver.com’ does require a password.
- Make some ssh keys on your client and then move the public key to the server
- cd ~/.ssh
- ls
- ssh-keygen -t dsa (Keep the defaults by just pressing enter a few times.)
- cp id_dsa.pub $USER”-id_dsa.pub”
- scp $USER”-id_dsa.pub” user@yoursever.com:.ssh/
- echo $USER (and remember name X so it can be used on other machine)
- Now set things right on the server
- ssh user@yourserver.com
- cd ~/.ssh
- cat X-id_dsa.pub >> authorized_keys
- rm X-id_dsa.pub
- exit
- Test things by verifying a ‘ssh user@yourserver.com’ no longer requires a password.
- Determine the directory to be backed up and where it will be backed up and test the command to be used.
- time rsync -atvz ~/local-directory-of-your-choosing/ user@youserver.com:remote-directory-of-your-choosing/
- log in the server and verify the files are there…
- Put the command in cron. Because cron is broken in ubuntu you can’t simply do “crontab -e” anylonger. (How can something so basic be broken?!) Instead follow these instructions:
- vi ~/some_file and put in the cron commands
- @hourly rsync -atvz ~/local-directory-of-your-choosing/ user@youserver.com:remote-directory-of-your-choosing/
- crontab ~/some_file
- crontab -l
Now simply test it out…