wfth / wordpress

0 stars 0 forks source link

Investigate how to back up a Wordpress site #6

Open aiwilliams opened 7 years ago

aiwilliams commented 7 years ago

As progress is made in a local environment we'll need to back up the database and the filesystem in a way that can be restored locally and to Dreamhost.com.

isaacjwilliams commented 7 years ago

@aiwilliams I don't know if this is a good idea but it seems to work pretty well.

backup.sh

cd ~/Documents/Programming/
cp -r neowisdomonline neowisdomonline-backup
zip -r9 neowo-backup.zip neowisdomonline-backup
rm -rf neowisdomonline-backup
aiwilliams commented 7 years ago

Does that include the database? You have to be a bit careful about database backups because the MySQL server provides tools to do it properly.

isaacjwilliams commented 7 years ago

@aiwilliams Haha, oops... It doesn't. But the new and improved version does! Note that it assumes your working directory is Documents/Programming/, your project is named neowisdomonline, and that you have a neowo host in your ssh config. :grimacing:

backup.sh

cd ~/Documents/Programming/
mkdir neowo-backup
cp -r neowisdomonline neowo-backup/filesystembackup

ssh neowo << EOF
mysqldump wordpress_default --result-file=/vagrant/neowo-dump.sql
logout
EOF

mv neowisdomonline/neowo-dump.sql neowo-backup/databasedump.sql
zip -r9 neowo-backup.zip neowo-backup
rm -rf neowo-backup
isaacjwilliams commented 7 years ago

We have discovered that we need only back up the uploads folder and the database. Now, I must write a restore script that unzips the backup, places the uploads and the database in their proper locations, and installs the theme and plugins.

isaacjwilliams commented 7 years ago

We'll want to use the Wordpress CLI to script theme and plugin installation.