Live data from Hacker News

Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

news.ycombinator.com

21–30 of 94 posts

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#21

Write a little program in your favorite shell or scripting language that * rsyncs the directories containing the files you want to back up * mysqldumps/pg_dumps your databases * zips/gzips everything up into a dated archive file * deletes the oldest backup (the one with X days ago's date) Put this program on a VPS at a different provider, on a spare computer in your house, or both. Create a cron job that runs it ever…

Yep. Here is an example that I use to upload it to dropbox. I don't delete and/or gzip my oldest uploads though. #!/bin/sh DATE=$(date +%d-%m-%Y@%H:%M:%S.%3N) DB_USER="qux" DB_PASS="foo" DB_NAME="bar" DROPBOX_TOKEN="baz" /usr/bin/mysqldump -u${DB_USER} -p${DB_PASS} ${DB_NAME} > /tmp/${DATE}.sql /usr/bin/curl -H "Authorization: Bearer ${DROPBOX_TOKEN}" https://api-content.dropbox.com/1/files_put/backup/ -T /tmp/${DATE…

Careful! If someone hacks your server, they now get your Dropbox account.

One alternative is to put these backups into S3 using pre-signed requests rather than Dropbox. An S3 pre-signed request gives permission only to upload files, perhaps only to a certain location in a certain bucket.

It's a bit harder to set up, but the shell script will look almost the same.

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#22

DigitalOcean has a droplet backup solution priced at 20% of the monthly cost of your droplet. Doesn't get much easier than that, if you can afford it. For a small droplet ($10/month) that's a full backup of everything for a buck a month. https://www.digitalocean.com/community/tutorials/understandi...

It's always good to have your backup off-site. If something happens to DigitalOcean servers, your backups will be gone too.

I imagine DO has some contingency plan to prevent both your server and the backup being down at the same time.

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#23

Write a little program in your favorite shell or scripting language that * rsyncs the directories containing the files you want to back up * mysqldumps/pg_dumps your databases * zips/gzips everything up into a dated archive file * deletes the oldest backup (the one with X days ago's date) Put this program on a VPS at a different provider, on a spare computer in your house, or both. Create a cron job that runs it ever…

[deleted]

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#24

Earlier quoted context omitted.

It's always good to have your backup off-site. If something happens to DigitalOcean servers, your backups will be gone too.

I imagine DO has some contingency plan to prevent both your server and the backup being down at the same time.

Well, most backups are for unseeable events. It's your choice to trust DO's contingency plans but I for one would like to put my eggs in multiple baskets, depends of the value of said eggs of course. I wouldn't set-up off-site backups for a personal website for example.

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#25
post #5

The simplest way for us it's to use rsync, there is this service decade old (even more) that is just perfect for the offsite backup. http://rsync.net/index.html We basically create a backup folder (our assets and MySQL Dump, then rsync it to rsync.net). Our source code is already on git, so basically backuped on Github, and all developers computer. On top of it, rsynch has a very clear and simple documentation to imp…

> clear and simple documentation

Not sure I'd agree there, but it's not inscrutable. I use rsync for almost all file transfers, backups included, so I'm used to it. But there are oddities here and yon.

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#26
Here's how we do it:

All the databases and other data are backed up to s3. For mysql, we use the python mysql-to-s3 backup scripts.

But the machines themselves are "backed up" by virtue of being able to be rebuilt with saltstack. We verify through nightly builds that we can bring a fresh instance up, with the latest dataset restored from s3, from scratch.

This makes it simple for us to switch providers, and can run our "production" instances locally on virtual machines running the exact same version of CentOS or FreeBSD we use in production.

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#27
Because I use Docker Cloud, I use Dockup to back up a certain directory daily to S3 from my DO VPS. https://github.com/tutumcloud/dockup

I just use a simple scheduled AWS lambda to PUT to the redeploy webhook URL.

I use an IAM role with put-only permissions to a certain bucket. Then, if your box is compromised, the backups cannot be deleted or read. S3 can also be setup to automatically remove files older than X days... Also very useful.

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#29
On OVH I rsync to another VPS in a different data center. I pick the lowest priced VPS with enough space. I also rsync to a local disk at my home. I would do the same with DO.

OVH has a backup by FTP premium service but the FTP server is accessible only by the VPS it backups. Pretty useless because in my experience if an OVH VPS fails the technical support has never been able to take it back online.

Re: Ask HN: How do you back up your site hosted on a VPS such as Digital Ocean?

#30
post #21

Earlier quoted context omitted.

Yep. Here is an example that I use to upload it to dropbox. I don't delete and/or gzip my oldest uploads though. #!/bin/sh DATE=$(date +%d-%m-%Y@%H:%M:%S.%3N) DB_USER="qux" DB_PASS="foo" DB_NAME="bar" DROPBOX_TOKEN="baz" /usr/bin/mysqldump -u${DB_USER} -p${DB_PASS} ${DB_NAME} > /tmp/${DATE}.sql /usr/bin/curl -H "Authorization: Bearer ${DROPBOX_TOKEN}" https://api-content.dropbox.com/1/files_put/backup/ -T /tmp/${DATE…

Careful! If someone hacks your server, they now get your Dropbox account. One alternative is to put these backups into S3 using pre-signed requests rather than Dropbox. An S3 pre-signed request gives permission only to upload files, perhaps only to a certain location in a certain bucket. It's a bit harder to set up, but the shell script will look almost the same.

You can actually set up app folders in Dropbox so that a particular API key effectively chroots you to that folder. The attacker would only get the backups.
Post reply on HN