Bluehost Self-Managed VPS and VDS: How to Schedule and Verify Backups
Regular, automated backups are one of the most important parts of running a Bluehost Self-Managed VPS or Virtual Dedicated Server (VDS). Bluehost doesn't currently offer a backup service for Self-Managed VPS or VDS plans, so backing up your data is your responsibility. This guide shows how to set up scheduled file and database backups (including Docker containers), use safer scripting approaches, and avoid common data-loss and security mistakes.
- These instructions apply to AlmaLinux 8/9/10, Rocky Linux 8/9/10, CentOS Stream 9/10, Fedora, Ubuntu, and Debian.
- For Dockerized apps (WordPress, n8n, LEMP, LAMP, Portainer), see How to Back Up Dockerized Apps for the right backup and database methods.
- Run the commands in this guide as
root. If you log in as a regular user, runsudo -ifirst to open a root shell. Output redirection (>) doesn't work withsudoalone. - We recommend verifying your backups by inspecting them, testing them, and, ideally, restoring them.
Why Schedule and Verify Backups?
- Automated, scheduled backups help you recover from mistakes, server failures, ransomware, and hacks.
- Verification (checking, testing, and restoring backups) helps confirm that you can recover your data when it matters.
- Native and Dockerized apps both need their own backup and restore strategies.
Create the Backup Directory
Create your backup directory before you run any backup job. This prevents backup jobs from failing and keeps your backups private. The second command makes the folder accessible only to the root user.
How to Schedule File and Directory Backups (All Distributions)
Back up a directory:
Example Output:
Change the path to any data directory you want to back up, such as /etc/ or /home/.
How to Schedule Database Backups (All Distributions)
MySQL and MariaDB (WordPress, LEMP, LAMP, and many other apps):
The --single-transaction option takes a consistent backup of InnoDB tables without locking them.
-p'password'). Anyone who can run ps aux on the server can see them. Instead, save your database credentials in a /root/.my.cnf file that only the root user can read.Create the file with the following contents, replacing the user name and password with your own:
Then restrict the file so only the root user can read it:
After that, mysqldump reads the credentials from the file, so you don't need any password options in your commands.
PostgreSQL (apps that use PostgreSQL, such as Odoo):
How to Use Cron for Automated Backups and Retention (All Distributions)
Use cron to schedule backups daily, weekly, or on whatever schedule you need.
Edit the root crontab:
Add a daily file backup at 2:00 AM and a daily database backup at 2:05 AM:
In a crontab, escape percent signs (%) with a backslash (\%). Otherwise, cron doesn't read the date correctly. The database job reads its credentials from /root/.my.cnf.
Backup rotation (automatic cleanup):
Without a cleanup job, daily backups eventually fill your server's disk. Add this job to your crontab to delete .tar.gz and .sql files in /backups that are older than 30 days. It runs daily at 4:00 AM.
/root/backup.sh, make it executable with chmod +x /root/backup.sh, and have cron run it, for example 0 2 * * * /root/backup.sh.How to Verify Your Backups
Check a backup archive's contents:
Replace YYYY-MM-DD with the date in your backup's file name.
Example Output:
Preview a database backup:
Example Output:
Test restores:
We recommend doing a test restore at least once a month. Restore to an isolated test server or a test database, not your live site, to confirm your backups work.
How to Back Up Dockerized Apps (WordPress, n8n, LEMP, LAMP, Portainer)
Follow these steps if you installed your software with a one-click install that runs in Docker containers with attached volumes.
List your running containers:
Example Output:
Some columns are left out of this example.
List your volumes:
Example Output:
The container and volume names on your server may differ from the examples in this section. Use the names from your own output.
Back up a data volume:
This example backs up the WordPress data volume:
Back up a database from inside a running Docker container:
If your database runs in a container, a mysqldump or pg_dump command on the server itself won't reach it. Run the command inside the container with docker exec instead.
MySQL and MariaDB containers:
Replace container_name and database_name with your own values. Many MySQL and MariaDB containers store the root password in an environment variable such as MYSQL_ROOT_PASSWORD. This command passes that value to mysqldump through the MYSQL_PWD environment variable instead of a -p option, so the password doesn't appear in the command line that ps shows. Check your container's settings for the variable name it uses. If mysqldump isn't found in a MariaDB container, use mariadb-dump instead.
PostgreSQL containers:
Replace container_name, username, and database_name with your own values.
Automate Docker backups and cleanup with cron:
Add these lines to your root crontab. The first line stops the container, backs up the volume, and always restarts the container, even if the backup fails.
Best Practices
- Keep a copy of your backups somewhere other than your server, such as a separate disk, a remote mount, or cloud storage. Backups stored only on your server's main disk can be lost along with the server.
- Limit how long you keep backups, using an automated cleanup such as
find ... -delete, so your disk doesn't fill up. - Test-restore your backups regularly, for example once a month.
- Back up your backup scripts and root crontab too, so you can rebuild your setup quickly after a failure.
- Keep passwords out of crontabs and scripts. Store them in files that only the root user can read.
Summary
Scheduling and verifying backups on your Bluehost Self-Managed VPS or Virtual Dedicated Server (VDS) helps you recover your files, apps, and databases if something goes wrong. Create a private backup directory, schedule backups with cron, use the Docker and database steps that match your setup, rotate old backups, and test your restores regularly.