Backup your Vultr VPS to Dropbox - Completely Automated!

edited August 2014 in Proposed How-Tos
Most of us have a harrowing time backing up our servers.

Here's an easy way. Assuming you are operating as root user.

1) Making the scripts

https://gist.github.com/n2j3/5276729

Copy this script, fill in the relevant details, include the relevant paths to backup and make backup1.sh script ( make a txt file, paste in notepad and then save as backup1.sh).

Go here -> https://github.com/andreafabrizi/Dropbox-Uploader
And download dropboxuploader.sh


Put them both in /root/ using ftp.

Assuming you made the first script in windows and simply downloaded the second one (dont need to edit the second one) you will need to change the encoding of backup1.sh to linux using the sed command

sed 's/\r$//' /root/backup1.sh /root/backup.sh


Now delete backup1.sh



2) Running the scripts and putting them in action?
What now?

Run backup.sh
/bin/bash /root/backup.sh

Now it will ask you to open dropbox account, create an app, name it, give it complete or single folder access, and then copy the Api keys. All the steps will be shown, its pretty straight forward.

Once this has run it will save the api keys and details so you wont have to save them again.



3) Automate it!

Make a cron job for this to execute this on a routine of your liking.

Use this - https://www.digitalocean.com/community/tutorials/how-to-use-cron-to-automate-tasks-on-a-vps

Take a minute to go through it. The commands are simple and very effective. I also hooked it up to email me (you can find how to email in the same tutorial)

I have fixed it to run everyday at 6am incase even i work late night the work is saved right before I go to sleep. So its saved like 29 August, 14.tgz to the application's dropbox folder. Remember the $now in first script will make a day's file(like above). So if you are saving multiple times a day you might want to change that to something that includes hours in the file name so its unique and doesn't get overwritten.




4) Sitback and relax

So once you have done that. You can sit back and relax cause dropbox will do the heavy lifting while you relax without worrying much about bad providers.


Incase in the future it stops working, the whole dropbox procedure is in the second script. Just use the same link above and download the new file and paste it in the older file's place. The maker of the script is awesome and keeps it updated.

Let me know if there can be variations of this. I am a linux noob and spent a lot of time figuring things out and thought i'd spread the joy here.

Dropbox has introduced 1TB backup for 10$ per month. So for 10$ a month, most of us with not a lot of data heavy vps can save a tonne of stuff there.

The First script also has a way to identify backups from multiple VPS/boxes. Just incase you have a lot of them, that will save you lot of time.

At the moment of writing this my backups are 50mb and the space on dropbox is 15gb (through referrals) So I can schedule cleaning up the dropbox account once a month and save weekly backups only.

Comments

Sign In or Register to comment.