Knife-Backup is a Knife plugin that can help you backup and restore a chef server. It is based on the great work of Steven Danna and Joshua Timberman on the BackupExport and BackupRestore plugins. Currently knife-backup has support for the following objects:
- clients
- users (chef 11 - Open Source)
- nodes
- roles
- environments
- data bags
- cookbooks and all their versions.
knife-backup will backup all cookbook versions available on the chef server. Cookbooks are normally available in a repository and should be easy to upload like that, but if you are using various cookbook versions in each environment then it might not be so trivial to find and upload them back to the server; downloading them and having them available to upload like that is simple and clean. If you have too many cookbook versions then you might want to cleanup them first using something like knife-cleanup
Users are a bit tricky, knife-backup can't gather the crypted passwords via the chef server so it's forced to reset them to a random string on restore. Be sure to copy them from the restore output or reset them.
Known limitation: currently it is not possible to overwrite a client object already available on the target server and these will be skipped.
You will need chef installed and a working knife config; it should work with chef versions newer than 0.10.10
gem install knife-backup
Currently the available commands are:
knife backup export [component component ...] [-D DIR] [options]
knife backup restore [component component ...] [-D DIR]
#Example:
knife backup export cookbooks roles environments -D ~/my_chef_backup
-N
,--latest
only download the latest version of a cookbook-I
,--ignore-permissions
ignore any permission errors during export
-I
,--ignore-metadata-errors
Ignore json metadata errors when restoring cookbooks
For more information on commands:
knife backup SUB-COMMAND --help
Note: you should treat this as beta software; I'm using it with success for my needs and hopefully you will find it useful too.
- Timestamp for the backup folder
- Track the failed downloads and report them at the end
- Find out if there is a way to overwrite a client object.
- Source hosted at GitHub
- Report issues/questions/feature requests on GitHub Issues
Pull requests are very welcome! Ideally create a topic branch for every separate change you make. For example:
- Fork the repo
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
Created and maintained by Marius Ducea ([email protected])
Based on the original plugins by Steven Danna and Joshua Timberman
Apache License, Version 2.0 (see LICENSE)