A bash script for creating encrypted WordPress backups using restic and storing them on remote storage.
- Exports WordPress databases using WP-CLI
- Creates encrypted backups of site files and database dumps
- Stores backups on remote storage using restic
- Handles backup scheduling with cron-like syntax
- Removes old backups based on retention policies
- Cross-platform compatible (macOS/Linux)
Environments may vary, a lot. Ideally you have SSH access to the system where the backup script should be periodically executed and the ability to install tools.
- SSH access
- Ability to install
resticandwp-cli - Ability to execute commands/scripts
- Ability to create cronjobs to automate backups
-
Install dependencies:
-
Clone this repository:
git clone https://github.com/haptiq/haptiq-backups.git cd haptiq-backups
The script should be executable after cloning the repository. If that's not the case, make the script executable:
chmod +x haptiq-backups.shCreate .env files in ~/.config/haptiq-backups/ for each site you want to backup. See example.com.env for a complete configuration example.
Run manually:
./haptiq-backups.shOr add to crontab for automatic execution:
# Check every 5 minutes
*/5 * * * * /path/to/haptiq-backups.shThe script compares the last backup time with the scheduled time from each site's configuration and only runs backups when they're due. This allows you to run the script frequently without creating unnecessary backups.
Licensed under the GNU General Public License v3 (GPLv3). See LICENSE file.
