Command line Backup and Restore for Drupal

This article shows a simple way to backup and restore both the files and data of a Drupal 6 website from the command line. Customize to taste and comment with recommendations for improvement.

Backup

WEBDIR=/home/www/public_html
BKPDIR=/home/www/backup
DBNAME=database
DBUSER=database-user
DBPASS=database-pass

mysqldump -u $DBUSER --password=$DBPASS $DBNAME > $BKPDIR/backup.sql
tar -cvf $BKPDIR/backup.tar $WEBDIR

Restore

WEBDIR=/home/www/public_html
BKPDIR=/home/www/backup
DBNAME=database
DBUSER=database-user
DBPASS=database-pass

mysql -u$DBUSER -p$DBPASS $DBNAME < $BKPDIR/backup.sql
tar -xvf $BKPDIR/backup.tar -C $WEBDIR

0
No votes yet
Your rating: None