A typical dynamic website such as Drupal, Wordpress, phpbb, Joomla, etc. consists of two parts you will need to download:
- The site files itself, such as images, .php, .html, .txt, .htaccess files and so on. Typically everything inside the /public_html folder.
- The database.
In this example I am going to download the files and db of my Drupal website http://philippinecarmarket.com.
Step 1: Compress the site files into one tar file.
Login via ssh and go to your root directory if you are not there already.
Use this command to tar:
tar cvzf 22maypcm.tar.gz --exclude='*.tar.gz' --exclude='*.gz' --exclude='*.sql' public_html/
’22maypcm.tar.gz’ – is the name I gave the file to as I usually name files by the date. You should develop and become comfortable with your own nomenclature system as you progress. You must also end it as *.tar.gz in order to get a gzip compressed file. If you just end your file as *.tar, it will download as uncompressed and will take much longer and be a much bigger file size.
The tar switches to compress is ‘cvzf‘, meaning in this order: c – create, v – verbose, z – compress / decompress, f – file.
I also use ‘--exclude‘ to keep other files such as other tar and archive files from adding onto it – an EXTREMELY useful tip to keep the file size low.
Check the result:
ls -l
You’ll see the file there in red 22maypcm.tar.gz, with a size of 99mb. To learn more, here’s a link to a fantastic guide re tar.
Step 2. Move the file to a location where you can download it.
Permissions on Drupal prevent you from downloading the file as it is, so let’s move it to the sites/default/files folder where you can download it via browser.
mv 22maypcm.tar.gz public_html/sites/default/files/
Now, check if it’s there.
ls -l public_html/sites/default/files/22maypcm.tar.gz
Yup there it is.
Step 3. Download via browser.
Enter the url on the browser:
http://yoururl.com/sites/default/files/22maypcm.tar.gz
It will now download directly to your computer.
Delete the file after you download it by:
rm /public_html/sites/default/files/22maypcm.tar.gz
Step 4. Download the db.
Using the excellend Backup and Migrate module, make a Manual Backup. Then go to
http:/yoururl.com/admin/config/system/backup_migrate/destination/list/files/manual
and download the latest backup. This will download the db to your PC.
You now have a backup of both your website files and your DB on your computer.
You would want to download your website to your PC for several reasons such as:
- You want to keep a backup ‘off-server’, that is: outside of the server it is hosted. Useful if some maintenance work is to be done on the server or the host is going out of business, or if you plan to host it elsewhere but have not yet decided where next.
- You want to host it on a local server to work on it using Xampp, Wamp, Mamp or other.
Alternatively, you may also use PhpMyAdmin if you have it, or make a manual backup by using the excellent and versatile mysqldump command (great reference here).
However it is my experience that the Backup and Migrate module produces a backup with the least amount of errors when uploading it again to another mysql installation using my favorite importer utility BigDump. We will cover using that in a later post.



