Backing up your VPS
NOTE: Work in progress.. currently just lecture notes
Outline:
- Setting up a backup server (perhaps)
- Advanced authentication with SSH keys
- Task scheduling with Cron
- Various backup methods (scp, rsync and rdiff-backup)
-
Setting up a backup server (perhaps)
- Ubuntu LTS (12.04/14.04)
- preferably not VPS, especially not with who you host your other stuff.
- doesn't need to be powerful, just have a spinning disk or two.
- Perhaps set up RAID? mdadm is great
- What is RAID?
- could be headless
- Ubuntu LTS (12.04/14.04)
-
Advanced authentication with SSH keys
- What are SSH keys?
- bit size, Algorithm RSA/DSM
- Password vs Password-less keys
- Setting up Keys:
- {lost? there is a great reference in these github docs}
- Basics, generate a key:
$> ssh-keygen
- this will use the default options and generate a key
- More advanced:
$> ssh-keygen -t rsa -b 2048 -f ./test -C "this is a test"
-t <type>
specify the algorithm: rsa1, dsa, ecdsa, rsa-b <bits>
this specifies the complexity of key, or the "key size", bigger is better usually.-f <filename>
name of the key-C "<comment here>"
give it a comment to recognize it.
- What are SSH keys?
-
Task scheduling with Cron
- What is cron?
- cron is a "task scheduler"
- need to do something every day at 3pm??, this is your tool
crontab -e
<some activation pattern> <some command here>
* * * * * /bin/bash /root/some.script
- this will run every minute of every hour of every day of every month@reboot /bin/bash /root/some.script
- this will run after every reboot@yearly /bin/bash /root/some.script
- this will run every year- { need more reference, this page is great }
- What is cron?
-
Various backup methods (scp, rsync and rdiff-backup)
- scp - "secure" copy, copies over an ssh connection
scp -r <from> <to>
- rsync - copies only the differences between local and remote copy
rsync -av <from> <to>
- rdiff-backup - only copies the diffs between local and remote copy, stores all versions of diffs.
rdiff-backup <from> <to>
- scp - "secure" copy, copies over an ssh connection