Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Backups

Julio Capote edited this page Nov 22, 2016 · 3 revisions

We've moved! Please visit our new wiki and update your bookmarks.

Overview

The packagecloud backup system currently handles 2 kinds of backups:

  • config backup, which backs up all configuration, gpg keys, rails secrets and user seed files in /etc/packagecloud/*

  • database backup, which is an percona xtrabackup [link] of the database

Settings

Backup configuration is located under the backups namespace in /etc/packagecloud/packagecloud.rb

# Controls whether config backups are taken regularly
backups['config_backup'] = false

# Controls whether database backups are taken regularly
backups['database_backup'] = false

# Where to store backups locally
backups['local_backup_path'] = "/var/opt/packagecloud/backups"

# Where to store backups on S3
backups['remote_backup_path'] = "backups"

# Controls whether we should upload backups to S3
backups['s3_upload'] = true

# How many backups to keep around
backups['keep_num'] = 10

# How often to take automatic backups, in seconds
backups['frequency'] = 86400 # 24 hours

# S3 Credentials
backups['aws_access_key'] = "XXXXXXXXXXXXX"
backups['aws_secret_key'] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

# Controls whether we should try to create the bucket before upload
backups['aws_create_bucket'] = true

# Name of S3 bucket to place backups
backups['aws_bucket_name'] = "packagecloud-backups-023f"

# S3 Region to use
backups['aws_region'] = "us-west-2"

Manual backups

You can take a backup at any time using sudo packagecloud-ctl backup-database or sudo packagecloud-ctl backup-config. It is recommended you do this before updates, especially if automatic backups are turned off.

You can take both a config and a database backup together by running sudo packagecloud-ctl backup-all instead of running separate commands if desired.

Note: Manual backups do not produce any logs, only STDOUT

Listing backups

To get a list of all database backups taken, run sudo packagecloud-ctl backup-database-list or sudo packagecloud-ctl backup-config-list for config backups.

Restore

To restore a backup, for example, a config backup located at /var/opt/packagecloud/backups/packagecloud-config-backup.1426626633.tgz, you can run sudo packagecloud-ctl backup-config-restore /var/opt/packagecloud/backups/packagecloud-config-backup.1426626633.tgz and it will restore from that backup. Same for database backups, just using sudo packagecloud-ctl backup-database-restore instead.

Restoring backup to a brand new computer

The procedures for restoring a config and database backup are as follows:

  1. apt-get install packagecloud or yum install packagecloud as usual but do not run sudo packagecloud-ctl reconfigure

  2. copy the most recent packagecloud-config-backup.tgz file to the new server

  3. copy the most recent packagecloud-database-backup.tgz file to the new server

  4. run sudo packagecloud-ctl backup-config-restore /path/to/packagecloud-config-backup.tgz

  5. now that your configuration and gpg keys are in place, sudo packagecloud-ctl reconfigure

  6. a site should now be running with your settings but a blank database

  7. run sudo packagecloud-ctl backup-database-restore /path/to/packagecloud-database-backup.tgz

  8. Now everything should be up and running like it was before

Troubleshooting

Logs for automatic config and database backups are available at /var/log/packagecloud/config-backups/current and /var/log/packagecloud/database-backups/current, respectively.

Note: Manual backups do not produce any logs, only STDOUT