How to Backup WordPress to Filebase Using Bash

Filebase is a durable, scalable, and secure object storage solution to store all your data at a safe and secure location. Filebase stores all objects redundantly across thousands of available zones globally. Filebase uses a browser-based dashboard and an S3-compatible API to deploy, access, and manage data across several decentralized storage networks.

This post will show you how to backup WordPress to Filebase using Bash.

Table Of Contents

Create a Bucket on Filebase

First, you will need to create a bucket on Filebase where you want to store your WordPress database and files. Follow the below steps to create a Filebase bucket.

Step 1 - First, sign in to your Filebase account.

Step 2 - Click on the Buckets on the left pane, you should see the following screen:

Step 3 - Click on the Create Bucket button. You should see the bucket creation screen:

Step 4 - Provide your bucker name, choose your storage location, and click the Create Bucket button. Once the bucket is created, you should see the following screen:

Step 5 - Click on the Access Keys on the left pane, you should see your Filebase access key and secrets on the following screen:

Please note down this access key, secret key, and API endpoint. You will need all to connect to the Filebase bucket.

Install S3cmd Tool

Next, you will need to install the S3cmd tool on your WordPress server from where you want to back up your MySQL database and website files.

First, install the Python and other dependencies by running the following command:

apt-get install python3 python3-setuptools curl -y

Next, download the latest version of S3cmd using the following command:

curl -LO https://github.com/s3tools/s3cmd/releases/download/v2.2.0/s3cmd-2.2.0.tar.gz

Next, extract the downloaded file with the following command:

tar -xvzf s3cmd-2.2.0.tar.gz

Next, navigate to the extracted directory and install it using the following command:

cd s3cmd-2.2.0
python3 setup.py install

Once the S3cmd is installed, verify the S3cmd version using the following command:

s3cmd --version

You will get the following output:

s3cmd version 2.2.0

Configure S3cmd to Connect WordPress Server to Filebase

Next, you will need to configure the S3cmd using the Filebase Access key and Secret key. You can configure it using the following command:

s3cmd --configure

You will be asked to provide your Filebase Access Key, Secret Key, Region, and Endpoint as shown below:

Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.
 
Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
Access Key: 54203D2S91DA6F043A3D
Secret Key: JSo3sFt7vMF1v3iISArDwWvzSHsPlSsroaL1591A
Default Region [US]: us-east-1
 
Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [s3.amazonaws.com]: s3.filebase.com
 
Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: %(bucket)s.s3.filebase.com
 
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/usr/bin/gpg]:
 
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP, and can only be proxied with Python 2.7 or newer
Use HTTPS protocol [Yes]:
 
On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name:
 
New settings:
Access Key: 54203D2S91DA6F043A3D
Secret Key: JSo3sFt7vMF1v3iISArDwWvzSHsPlSsroaL1591A
Default Region: us-east-1
S3 Endpoint: s3.filebase.com
DNS-style bucket+hostname:port template for accessing a bucket: %(bucket)s.s3.filebase.com
Encryption password:
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: True
HTTP Proxy server name:
HTTP Proxy server port: 0
 
Test access with supplied credentials? [Y/n] Y
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)
 
Now verifying that encryption works...
Not configured. Never mind.
 
Save settings? [y/N] y

Once the S3cmd is configured, you can verify your bucket information using the following command:

s3cmd info s3://wordpress-filebase/

You will get the following output:

s3://wordpress-filebase/ (bucket):
Location: us-east-1
Payer: none
Expiration Rule: none
Policy: <?xml version="1.0" encoding="UTF-8"?><ListBucketResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Name>wordpress-filebase</Name><Prefix/><Marker/><MaxKeys>1000</MaxKeys><IsTruncated>false</IsTruncated></ListBucketResult>
CORS: none
ACL: simon@snapshooter.io: FULL_CONTROL

Use S3cmd to Backup WordPress to Filebase Bucket

First, log in to your WordPress server and connect to the MariaDB shell with the following command:

mysql -u root -p

Once you are logged in, list all available databases using the following command:

MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| wordpress |
+--------------------+

Next, backup your WordPress database using the following command:

mysqldump -u wordpressuser -p wordpress > wordpress.sql

Next, run the S3cmd command to copy the wordpress.sql file to the Filebase Bucket:

s3cmd put wordpress.sql s3://wordpress-filebase/

You should see the following output:

upload: 'wordpress.sql' -> 's3://wordpress-filebase/wordpress.sql' [1 of 1]
10485760 of 10485760 100% in 1s 6.56 MB/s done

Next, run the S3cmd command again to copy the WordPress website data to the Filebase Bucket:

tar -czvf - /var/www/html/wordpress | s3cmd put - s3://wordpress-filebase/wordpress.tar.gz

Output:

upload: '<stdin>' -> 's3://wordpress-filebase/wordpress.tar.gz' [part 2 of -, 5MB] [1 of 1]
5434996 of 5434996 100% in 0s 18.77 MB/s done

You can now verify all backups on the Filebase Bucket using the following command:

s3cmd ls s3://wordpress-filebase

You will get the following output:

2022-07-15 05:31 10485760 s3://wordpress-filebase/wordpress.sql
2022-07-15 05:31 21163636 s3://wordpress-filebase/wordpress.tar.gz

You can also log in to the Filebase Bucket and verify your WordPress backup files as shown below:

Conclusion

This post explained how to back up the WordPress database and website data to Filebase Bucket using bash. Now, you can create your own backup script using the s3cmd tool to backup your WordPress database and website data to Filebase Bucket.

Scheduled WordPress Backups SnapShooter

Backup a WordPress website, database (MySQL) and the file system

Learn more about WordPress Backups

Get started for free
No credit card required. Cancel anytime!
Was this page helpful?

Thank you for helping us improve!