Command line tools to backup your drupal files and database

Two command line scripts that are great solutions to backing up your drupal database and filesystem.
Sure there are tons of ways to do this but these two have worked well for me for numerous years. And since they are command line tools, once in place they just work.

rdiff-backup
This is a great way to do incremental backups and it can even do remote backups. All you need to do is run it at night via cron. For example
rdiff-backup /home/admin/public_html /home/admin/backups/filesystem
That will backup my site to the filesystem folder I made for it.
Then I can look in the filesystem folder with my FTP client, or SFTP client or command line and see the site just like normal but with yesterdays files. It only backups up the latest changed files so it does not get out of hand. BUT if I want to get files from 10 days ago I would run
rdiff-backup -r 10D /home/admin/public_html /tmp/testrecover
This would send the restored files to /tmp/testrecovered or anywhere I want to check them out before I decide the file or files where the ones I wanted. I could do the entire site or just one file.
rdiff-backup -r 10D /home/admin/public_html/sites/default/files/image.png /tmp/testrecover

More info can be seen here
http://www.nongnu.org/rdiff-backup/examples.html

automysqlbackups.sh
Another great script that makes Daily, Weekly and Monthly backups of my database!

You download the file and modify the settings in the file
1. db username
2. db password
3. dbs to backup
4. where to backup to

I tend to put ALL for the db to backup and just let it backup the dbs the user has access to.

As far as what goes where goes I tend to do this.
1. I make a folder called backups in the home folder of the user in charge of this site.
2. in there are
a. the two scripts automysqlbackups.sh and filesystem.sh
b. two folders mysql and filesystem

So the filesystem.sh script runs my rdiff-backups backups into the filesystem folder. All it has in it is this line
rdiff-backup /home/admin/public_html /home/admin/backups/filesystem

And the automysqlbackups.sh does the db backups in mysql folder.

Then my cron ends up looking like this (consider /home/admin is in charge of the site)
30 22 * * * /home/admin/backups/filesystem.sh
30 22 * * * /home/admin/backups/automysqlbackup.sh

So all the scripts and backups live in that /home/admin/backups folder.

Site for automysql
http://sourceforge.net/projects/automysqlbackup/

Faceted Search

Related by tag

Drupal Planet, og, organic groups

drupal, views

drupal

developer, drupal, php

drupal, panels, views

drupal, mobile, panels

cck, Drupal Planet, views

drupal, Drupal Planet, security

Drupal Planet, twitter

cache, cookies, Drupal Planet, sessions

drupal, Drupal Planet

cron, Drupal Planet

101, Drupal Planet, rules

drupal, usability

drupal, ubercart

drupal, mac, mamp

drupal, Drupal Planet, omega

Author Profile

Alfred Nutile's picture
Alfred Nutile

Not counting my Commodore 64 years, I began my IT career when Windows 95 hit the scene and Google was just a glimmer on the Californian horizon. I discovered Drupal four years ago when it was giving Joomla a run for its money.
 
At the time, I was working as the IT manager at the National Priorities Project (NPP). We were using Joolma and getting about 200,000 visitors a month and the site was not scaling well.  I saw the limits of Joomla and the promise of Drupal 4 with its taxonomy system, clean urls, and security features.  I converted NPP to Drupal and migrated their main database,  http://nationalpriorities.org/nppdatabase_tool, from webobjects to a Drupal-friendly structure in MySQL.  Still not satisfied, I moved NPP’s constituent data (including their 25,000 member email list) out of the expensive Raiser's Edge and into the free and open source CiviCRM 1.8, saving the company money that it was spending on their desktop software.
 
Thus began my commitment to supporting non-profits by creating affordable, custom-built content management systems in Drupal and CiviCRM. I founded River Valley Tech Collective as a collaborative team of other like-minded techies to provide Drupal-driven sites to a wider range of non-profits, educational institutions and local community organizations.