Page 2 of 2

Re: What are you using to back up your WordPress site?

Posted: Mon Aug 06, 2018 9:42 pm
by patty1
Hi, Drew. Thank you very much for this shell script. I'm not afraid to try shell executables and chmod, so I'll give it a try.

A couple of questions.

I notice that the first line refers to bash. I normally run csh. Should I switch to bash before running this program?

In case I need to use the files to restore my configuration, are you saying that I would unzip the tar.gz file and then copy each file back to the database to overwrite it?

Thanks.

Re: What are you using to back up your WordPress site?

Posted: Tue Aug 07, 2018 4:51 pm
by drew.phillips
You shouldn't need to switch to bash before running it, but when you do execute it, it will run inside a bash shell. The syntax between csh and bash scripts are slightly different.

In order to restore your site from a backup taken with this, you would follow these steps from shell:

Code: Select all

# restore mysql backup.  this will prompt for DB password
# after entering password, it will drop all wordpress tables and restore them from the backup
mysql -u DB_USER -p DB_NAME < ~/wordpress_backups/wordpress-date.sql

# restore the file backup
tar -v -z -C / -xf ~/wordpress_backups/wordpress-date.tar.gz
The backup was taken leaving the path preceding all the files, so the "-C /" option extracts the archive to the root of the server so the paths resolve back into /home/u/username/public_html/domain.tld. If you were restoring due to a website compromise, another option would be to extract the tar to a temporary location, and then use rsync to restore the files and delete extraneous files (those that were not in the backup) after it restores.

So it's a pretty simple two step process.

1. Restore the MySQL database with mysql
2. Extract the files from backup and overwrite or restore the site to the hosting directory