Tuesday, 16 November 2010

How to backup/restore site and mysql database

Frequently you would need to back up and restore site's files and database

-To backup drupal files, better to compress them first so go to the root:

tar -cvjf site.tar.bz2 /path/to/site

- To decompress the above:

tar -xjvf site.tar.bz2

- To backup mysql database ('username' is Mysql username)

mysqldump -u username -p databasename > /path/to/dumpfile.sql

- Also it is better to compress the database if you need to download it:
tar -xjvf dumpfile.sql.tar.bz2 /path/to/dumpfile.sql

- To restore a backed up mysql databas (after decompressing it)

mysql -u username -p databasename < /path/to/dumpfile.sql

No comments:

Post a Comment