Backing up Gandalf¶
You can use the misc/backup.bash script to make a backup of authorized_keys and repositories files created by gandalf, and misc/mongodb/backup.bash to make a backup of the database. Both scripts store archives in S3 buckets.
The backups script sends these data to the s3 using the s3cmd tool.
First, make sure you have installed s3cmd. You can install it using your preferred package manager. For more details, refer to its download documentation.
Now let’s configure s3cmd, it requires your amazon access and secret key:
$ s3cmd --configure
To backup the Mongo database, you can use the generic script backup.bash present in the misc/mongodb directory. It’s pretty straightforward to use:
$ ./misc/mongodb/backup.bash s3://mybucket localhost database
As in the previous script, the first parameter is the S3 bucket. The second parameter is the database host. You can provide just the hostname, or the host:port (for example, 127.0.0.1:27018). The third parameter is the name of the database.
There is another useful script in the misc/mongodb directory: healer.bash. This script checks a list of collections and if any of them is gone, download the last three backup archives and fix all gone collections.
This is how you should use it:
$ ./misc/mongodb/healer.bash s3://mybucket localhost mongodb repositories users
The first three parameters mean the same as in the backup script. From the fourth parameter onwards, you should list the collections. In the example above, we provided two collections: “repositories” and “users”.