What are you using to back up your WordPress site?

Web hosting discussion, programming, and shared and dedicated servers.
12 posts Page 2 of 2
by patty1 » Mon Aug 06, 2018 9:42 pm
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.
by drew.phillips » Tue Aug 07, 2018 4:51 pm
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
Drew Phillips
Programmer / System Operations, Sonic.net
12 posts Page 2 of 2

Who is online

In total there are 30 users online :: 0 registered, 0 hidden and 30 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 30 guests