rysnc from production to local
To copy the contents of the remote directory into a directory in your local, See note below about trailing '/':
sudo rsync -chavzP --stats --delete --exclude sites/default/settings.php user@remote.host:/path/to/copy/ /path/to/local/storage (see http://stackoverflow.com/questions/9090817/copying-files-using-rsync-fro...)
Note the exclude is so the sites/default/settings.php is not copied since this has the settings for the mysql database. We don't want the local using the production database.
The switches are:
-c, --checksum skip based on checksum, not mod-time & size
-h, --human-readable output numbers in a human-readable format
-a, --archive archive mode; equals -rlptgoD (no -H,-A,-X)
-v, --verbose increase verbosity
-z, --compress compress file data during the transfer
-P same as --partial --progress
--stats give some file-transfer stats
-- delete delete files from the destination directory if they are not in the source
--exclude 'file' source/ destination/
!!!Be careful when rsyncing with trailing slashes. The command given by Johnnysweb would create a directory called copy inside /path/to/local/storage. Like so /path/to/local/storage/copy. If that's what you want great. However a more common scenario is you want to copy the contents of the remote directory into a directory in your local. Then you would do /path/to/copy/ which would place the contents inside the directory /path/to/local/storage without creating a local copy directory.
After rsync.
Use phpmyadmin or mysql command line to drop the database of the destination web site.
Create a new database with the same name. Previous user will have the same priveages as on the old database.
Use mysql command line to load a backup of the production database (backup has to be an uncompressed copy):
- mysql -u root -p
- mysql use 'name of destination database'
- mysql source production_backup.mysl