Backing up Drupal Quickly

I must admit, updating a Drupal instance, even if it’s one module is a bit scary. And a rule of thumb is: backup, backup and backup the backup. So I do it.

Below I post a script that I wrote for that purpose (my first script for Linux :D). The folder structure on my server is:


The Script

today=$(date +"%Y-%m-%d")

cd ~/
mkdir $backups/$today


echo -e "TODAY: $today\n"

# 1.
echo "---Backing up Drupal 6.x without uploaded files---"

tar --create --gzip --file=$backups/$today/drupal-$drupal_v-no-files.tgz --exclude='sites/default/files' \
--directory=public_html drupal-6.x

echo -e "DONE\n"

# 2.
echo "---Backing up Drupal 6.x uploaded files---"

tar --create --gzip --file=$backups/$today/files.tgz --directory=public_html/drupal-6.x/sites/default files

echo -e "DONE\n"

echo "---Dumping the database---"

/usr/local/mysql/bin/mysqldump -u YOU -p --default-character-set=utf8 --result-file=$backups/$today/dump.sql DB
tar --create --gzip --file=$backups/$today/dump.sql.tgz --directory=$backups/$today dump.sql

echo -e "DONE\n"

echo "---Copying the settings---"

cp public_html/drupal-6.x/sites/default/settings.php public_html/drupal-6.x/.htaccess $backups/$today

echo -e "DONE\n"

echo "FINISHED. Please move the backup files to a safe location"

2 Responses to “Backing up Drupal Quickly”

  1. Rachel Morris Says:

    great points altogether, you just won a new reader.
    What may you recommend in regards to youhr submit that you mmade a few days in the past?
    Any certain?

  2. Ervin McGraw Says:

    I was excited to ind this great site. Iwanted to thank you for your time for this fantastic read!!
    I definitely enjoyed every bit of it and i also have you book-marked to check out new stuff
    on your web site.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: