58°F

Aaron Parecki

  • Articles
  • Notes
  • Photos
  • How to back up Dropbox automatically - daily, weekly, monthly snapshots

    July 9, 2010

    Dropbox is great. Most of the time. It's great when I need to easily share files with people while working on a project together. It keeps files in sync between multiple computers, and is the only solution I've found so far which works seamlessly and instantaneously. If you don't already use it, I highly recommend it.

    Dropbox - Online file backup and sharing

    I've recently been having problems with Dropbox ever since joining a shared folder which overflowed my quota. Completely unrelated files mysteriously disappeared. Luckily I had a snapshot from before I had joined the folder and was able to restore the files.

    This prompted me to set up a proper backup system which makes snapshots daily, weekly and monthly.

    This guide assumes you have a Linux server somewhere with no GUI.

    First, follow the Dropbox wiki instructions for installing Dropbox on Linux. The process is relatively painless, and seems to just work. At the end, you'll end up with a "Dropbox" folder in your home folder. This folder will always have the latest version of your files.

    The next step is to take snapshots of that folder at regular intervals. I chose to keep 7 days of daily snapshots, 4 snapshots taken weekly, and 12 taken monthly. In theory, this should give me access to any files I've accidentally deleted within the past year.

    This script will run rsync to clone the Dropbox folder into snapshot folders which will be overwritten over time, so you will only end up with 7+4+12 copies of your Dropbox folder. Save this code to a file called backup.sh or whatever you want, and make it executable (chmod 755 backup.sh).

    backup.sh:

    #!/bin/bash
    
    # Makes daily snapshots in folders like "daily-4-Thu", "daily-5-Fri"
    if [[ "$1" == "daily" ]]
    then
            path=daily-`date +%u-%a`
    fi
    
    # Makes weekly snapshots in folders like "weekly-1" where 1 is the day of the month
    if [[ "$1" == "weekly" ]]
    then
            path=weekly-`date +%d`
    fi
    
    # Makes  monthly snapshots in folders like "monthly-04-Apr"
    if [[ "$1" == "monthly" ]]
    then
            path=monthly-`date +%m-%b`
    fi
    
    # Run with "go" as the second CLI parameter to actually run the rsync command, otherwise prints the command that would have been run (useful for testing)
    if [[ "$2" == "go" ]]
    then
            rsync -avz --delete /home/aaron/Dropbox /home/aaron/aaron/Dropbox-Backup/$path
    else
            echo rsync -avz --delete /home/aaron/Dropbox /home/aaron/Dropbox-Backup/$path
    fi
    

    Add these lines to your crontab to run the backup script at the appropriate intervals. This will run the daily script every night at 1am, the weekly script on the 4th, 12th, 20th and 28th days of the month at 1:30am, and the monthly script on the 1st of the month at 2am.

    crontab:

    0 1 * * * /home/aaron/backup.sh daily go
    30 1 4,12,20,28 * * /home/aaron/backup.sh weekly go
    0 2 1 * * /home/aaron/backup.sh monthly go
    

    Hopefully this saves you some headaches down the road when Dropbox decides to play tricks on you.

    Fri, Jul 9, 2010 2:42pm -07:00 #backup #cloud #dropbox #ownyourdata #snapshots
Posted in /articles

Hi, I'm Aaron Parecki, Director of Identity Standards at Okta, and co-founder of IndieWebCamp. I maintain oauth.net, write and consult about OAuth, and participate in the OAuth Working Group at the IETF. I also help people learn about video production and livestreaming. (detailed bio)

I've been tracking my location since 2008 and I wrote 100 songs in 100 days. I've spoken at conferences around the world about owning your data, OAuth, quantified self, and explained why R is a vowel. Read more.

  • Director of Identity Standards at Okta
  • IndieWebCamp Founder
  • OAuth WG Editor
  • OpenID Board Member

  • 🎥 YouTube Tutorials and Reviews
  • 🏠 We're building a triplex!
  • ⭐️ Life Stack
  • ⚙️ Home Automation
  • All
  • Articles
  • Bookmarks
  • Notes
  • Photos
  • Replies
  • Reviews
  • Trips
  • Videos
  • Contact
© 1999-2025 by Aaron Parecki. Powered by p3k. This site supports Webmention.
Except where otherwise noted, text content on this site is licensed under a Creative Commons Attribution 3.0 License.
IndieWebCamp Microformats Webmention W3C HTML5 Creative Commons
WeChat ID
aaronpk_tv