If you have SSH access to your server, you can create a bash script to automate full backups of your CubeCart store (database and files).

The Backup Script

Create a file called backup.sh in your store’s root directory:

#!/bin/sh
DBSERVER="localhost"
DATABASE="your_database_name"
DBUSER="your_database_user"
DBPASSWORD="your_database_password"

STOREDIR="/path/to/your/cubecart"
BACKUPDIR="/path/to/backups"
DATE=$(date +%Y-%m-%d)

# Create backup directory
mkdir -p $BACKUPDIR/$DATE

# Dump the database
mysqldump -h $DBSERVER -u $DBUSER -p$DBPASSWORD $DATABASE | gzip > $BACKUPDIR/$DATE/database.sql.gz

# Archive the store files
tar -czf $BACKUPDIR/$DATE/files.tar.gz -C $STOREDIR .

# Remove backups older than 30 days
find $BACKUPDIR -type d -mtime +30 -exec rm -rf {} +

echo "Backup completed: $BACKUPDIR/$DATE"

Setup

  1. Replace the placeholder values with your actual database credentials and paths. You can find database details in includes/global.inc.php.
  2. Make the script executable: chmod +x backup.sh
  3. Test it: ./backup.sh

Automate with Cron

To run the backup daily at 2am, add a cron job:

crontab -e

Then add:

0 2 * * * /path/to/your/cubecart/backup.sh

Important Notes

  • Store backups in a location outside your web-accessible directory.
  • Consider copying backups to an offsite location (cloud storage, another server).
  • The script retains 30 days of backups by default — adjust as needed.
  • Ensure the backup directory has sufficient disk space.

On Official CubeCart Hosting

Daily automated backups with 3-month retention are included with all plans. No script needed.