Self-Hosted Backups and Restores

Backups of Hudu

Manual Backup of Hudu Postgres

  • Login into the server you want to back up.
  • Run cd ~/hudu2
  • Make sure the server is up and running.
  • Run: sudo docker-compose exec -T db pg_dump -U postgres hudu_production > NAME-OF-DUMP.sql
  • This file can now be moved onto a new server to be used. Make sure to keep the same .env variables.

 

Auto-Backup Script to S3

There are two aspects of Hudu you will need to back up. The first is your database. There are multiple ways to automatically back up Postgres databases. One simple way is to add to the end of your docker-compose.yml:

  postgres3:
    image: hudusoftware/doubletake:latest
    restart: unless-stopped
    links:
      - db
    environment:
      S3_HOST_BASE: 's3.us-west-1.wasabisys.com'
      S3_REGION: 's3.us-west-1'
      S3_BUCKET: 'bucketname'
S3_FOLDER: 'foldername' S3_ACCESS_KEY_ID: 'XXXX' S3_SECRET_ACCESS_KEY: 'XXXXXXXX' CRON_SCHEDULE: '0 */6 * * *' DB_NAME: 'hudu_production' DB_USER: 'postgres' POSTGRES_PASSWORD: DB_HOST: 'db'
DB_BACKUP_VERIFY: '1'
DB_BACKUP_COMPRESS: '1' POSTGRES_EXTRA_OPTS: '--schema=public --blobs'

 

You will need to manually verify the integrity of these backups.

 

To run a manual backup:

 sudo docker compose exec -T postgres3 /backup.sh

The other aspect you need to back up is object storage for your uploaded files. You can use s3cmd, AWS CLI, and more to do this.

Here is an example that will backup your files to your local system, using AWS CLI:

  aws s3 sync s3://your-bucket-name /home/ubuntu/s3/your-bucket-name/

 

Restoring a database backup

Once you have a database backup, you can restore your Hudu instance to the old backup by following these steps:

  • Make sure you have an up-to-date backup of your documentation before you begin.
  • Move the .sql database dump file into the ~/hudu2 directory. Typically, the easiest way to move files is via SCP or SFTP.
  • Run sudo docker-compose down to bring your instance down.
  • Run sudo docker-compose up -d db
  • Run the command: sudo docker-compose exec db dropdb hudu_production -U postgres
  • Run the command: sudo docker-compose exec db createdb hudu_production -U postgres
  • Run the command: cat NAME-OF-DUMP.sql | sudo docker-compose exec -T db psql -d hudu_production -U postgres
  • Run sudo docker-compose down
  • Run sudo docker-compose up -d to get your instance back up and running!

 

Backing up/Restoring files

Local storage

When using local storage, files are located here: /var/lib/docker/volumes/hudu2_app_data/_data/ . To restore, just move from the old server to the new server, same directory.

 

S3 Bucket Storage

We recommend using lifecycle rules to back up S3 to Amazon Glacier. 

When using other storage, we recommend S3 CLI to back up or migrate.

 

Moving from object to local or vice versa

Both local and object storage will have the same directory structure, just make sure to move from /var/lib/docker/volumes/hudu2_app_data/_data/ when using local storage.

 

 

Was this article helpful?
1 out of 2 found this helpful