Zip a directory but exclude certain folders, but why?

I wanted to backup my WordPress site but exclude the backups folder, so this command came in handy.

zip -r /home/mysite/backups/ /home/mysite -x /home/mysite/backups/**\*

For the database backup I exported it as a sql file using WP-CLI.

wp export db

The zip file then can be transferred using SCP.

scp /home/mysite/backups/ [email protected]:/tmp/
scp /home/mysite/database.sql [email protected]/tmp/ 

Relocate the zip file and database.

mv /tmp/ /home/newsite/
mv /tmp/database.sql /home/newsite/

Import Database.

wp import db database.sql


wp search-replace 'mysite.domain' 'newsite.domain' --skip-guid=columns


Congratulations, now check it all works.

Leave a Comment

You must be logged in to post a comment.