Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Tutorial: Basic website and database backups with Duplicity
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Tutorial: Basic website and database backups with Duplicity

RaymiiRaymii Member
edited February 2013 in Tutorials

This tutorial will show you how you can back up your website and database with Duplicity. Duplicity is a very useful tool to make remote unassisted backups. The backups can be incremental, encrypted, and over a variety of transports.

There are a few steps involved in the process of setting this up, and also a few preconditions:

  • The tutorial works best with a VPS, were you have full root access to the filesystem and database
  • The tutorial is targeted at debian/ubuntu, but with adaption of commands will work under CentOS/RHEL.
  • You need an off-site location to store the backups (other vps for example)

Basic web application backup

First I'll try to educate you a little bit with some theory.

This tutorial works for all web applications, since they almost all share the same common structure:

  • source code (.php files, .js files (node), .rb files (rails) etc.)
  • database (MySQL, PostgreSQL, MongoDB etc.)
  • configuration (apache config, nginx config, mysql config, application config)

We are going to back up files. Two of the three things above are already files, and the database will be exported to a file. The database will be exported so that it can be imported again using native tools (mysqldump, mongodump etc.), since just copying the database folders and files will almost always result in a corrupted database.

Duplicity has a few advantages to other backup tools and scripts:

  • Incremental backups (Saving size)
  • A lot of storage options (ssh, rsync, ftp, amazon S3, IMAP, google drive and more.)
  • Encryption built in
  • Easy to set up and maintain.

I myself have the following set up for almost all of my web application backups:

  • Shell script to export the databases
  • Duplicity backing up the files to a "storage" VPS
  • The storage vps is just a server with a lot of HDD space doing nothing else.
  • Some apps back up daily, some hourly and some weekly.

Read the rest of the tutorial over at Raymii.org

Comments

  • Awmusic12635Awmusic12635 Member, Host Rep

    Thanks for the helpful guide

  • Awesome guide. Been looking for an alternate backup solution.

  • AnthonySmithAnthonySmith Member, Patron Provider

    Loving the guides you write, great community spirit :)

  • Maybe you can change this to the tutorials section

  • 404?

  • InfinityInfinity Member, Host Rep
    edited February 2013

    Great stuff @Raymii, changed the section to tutorials. :)

    Also sent a PM.

    @fly said: 404?

    The link loads fine for me.

  • rm_rm_ IPv6 Advocate, Veteran
    edited February 2013

    @Raymii
    your website does not load for me, and that's since quite some time ago.
    http://ompldr.org/vaGkzYw/2013-02-17T220925Z-raymii.png
    Basically despite over 9000 IPs on the hostname, all your IPv6 is down.
    Do you ever test it yourself?

    # curl -vvv6 https://raymii.org/s/tutorials/Website-and-database-backup-with-Duplicity.html
    * About to connect() to raymii.org port 443 (#0)
    *   Trying 2a00:dcc0:eda:88:245:71:6b8:eae1... Connection refused
    *   Trying 2a00:dcc0:eda:88:245:71:5a7a:4ec6... Connection refused
    *   Trying 2607:f358:1:fed5:22:0:beb8:953a... Timeout
    *   Trying 2607:f358:1:fed5:11:0:1071:3... Timeout
    *   Trying 2001:1608:10:38::f57a:8696... Connection refused
    *   Trying 2607:f358:1:fed5:22:0:d274:c869... Timeout
    *   Trying 2607:f358:1:fed5:22:0:7454:5742... Timeout
    *   Trying 2607:f358:1:fed5:22:0:6b58:59f3... Timeout
    *   Trying 2607:f358:1:fed5:22:0:4fd9:ca83... Timeout
    *   Trying 2607:f358:1:fed5:22:0:3432:4274... Timeout
    *   Trying 2607:f358:1:fed5:22:0:8dc7:4fb5... Timeout
    *   Trying 2607:f358:1:fed5:22:0:d562:72e8... Timeout
    * couldn't connect to host
    * Closing connection #0
    curl: (7) couldn't connect to host

    ^ the above took ~5 minutes until all the timeouts expired.

  • mikhomikho Member, Host Rep

    @Raymii

    Had a draft going for this myself, mind if I copy yours instead? Full credit towards you ofcourse.

  • AndriAndri Member
    edited February 2013

    @Raymii Dude, you rocks! Thanks! :D

  • Thank you! I'm working to improve my backup settings, this helped a lot!

  • Or you can use CodeGuard.

  • For those interested in using encryption with your backups. I send my backups to S3.

    http://www.kubicle.com/automate-encrypted-backups-using-amazon-s3-duplicity/

  • SaahibSaahib Host Rep, Veteran

    That was sweet and simple.. quite helpful as I have good idea about duplicity now.

  • RaymiiRaymii Member
    edited February 2013

    your website does not load for me, and that's since quite some time ago.
    http://ompldr.org/vaGkzYw/2013-02-17T220925Z-raymii.png
    Basically despite over 9000 IPs on the hostname, all your IPv6 is down.
    Do you ever test it yourself?

    @rm_
    IPv6 indeed has an issue. I've recently upgraded all the servers to Debian Wheezy, before than I can confirm it worked. I've disabled IPv6 until I find out what the issue is. Thanks for reporting it.

    @MikHo said: Had a draft going for this myself, mind if I copy yours instead? Full credit towards you ofcourse.

    @Mikho
    Sure go ahead. Quoting my website's disclaimer/license:

    All the text on this website is free as in freedom unless stated otherwise. This means you can use it in any way you want, you can copy it, change it the way you like and republish it.
    

    (https://raymii.org/s/static/Disclaimer.html)

  • Hi,

    Is there any centos/cpanel server version of this? thx

  • @niceboy said: Is there any centos/cpanel server version of this? thx

    Change apt-get install to yum install and you have a centos version.

  • @Raymii Thank you for that instructive and simplified tutorial. Glad to have learn something.

    Cheers!

Sign In or Register to comment.