Wordpress Backup with Bash
Learn how to backup WordPress to Filebase using Bash.
What is WordPress?
WordPress is a free and open source website and content management system that uses MySQL or MariaDB databases. WordPress is a popular option for hosting personal websites and blogs.
Read below to learn how to backup WordPress to Filebase using Bash.
Special thanks to Simon Bennett from SnapShooter for the original version of this tutorial.
1. Start by installing the S3cmd tool on your WordPress server with the following commands:
apt-get install python3 python3-setuptools curl -y
curl -LO https://github.com/s3tools/s3cmd/releases/download/v2.2.0/s3cmd-2.2.0.tar.gz
tar -xvzf s3cmd-2.2.0.tar.gz
cd s3cmd-2.2.0
python3 setup.py install
2. Verify S3cmd was installed correctly using the following command to display the installed version:
s3cmd --version
3. Next, configure S3cmd for use with Filebase:
s3cmd --configure
4. You will be prompted to enter the following configuration details:
Access Key: Filebase Access Key
Secret Key: Filebase Secret Key
Default Region: us-east-1
S3 Endpoint: s3.filebase.com
Overall, your configuration output should resemble the following:
5. Test your configuration using the following command:
S3cmd info s3://filebase-bucket-name
Replace filebase-bucket-name
with your Filebase bucket name. The output should resemble the following:
6. Next, login to your WordPress server’s MariaDB instance with the following command:
mysql -u root -p
7. Then, backup the WordPress database with the following command:
mysqldump -u wordpressuser -p wordpress > wordpress.sql
8. Run the following S3cmd command to copy the wordpress.sql file into your Filebase bucket:
s3cmd put wordpress.sql s3://filebase-bucket-name/
Replace filebase-bucket-name
with your Filebase bucket name.
9. Then, run another S3cmd command to copy your WordPress website data into your Filebase bucket as well:
tar -czvf - /var/www/html/wordpress | s3cmd put - s3://wordpress-filebase/wordpress.tar.gz
10. Verify that all files have been uploaded correctly using the following command:
s3cmd ls s3://filebase-bucket-name
The output will resemble the following:
2022-08-08 05:31 10485760 s3://filebase-bucket-name/wordpress.sql
2022-08-08 05:31 21163636 s3://filebase-bucket-name/wordpress.tar.gz
Looking for an easier, automated way to backup Wordpress to Filebase? Snapshooter allows you to schedule automated backups to Filebase for free, no credit card required. Get started today here.
Last updated