This repo contains a sample script to back up OneFuse Policies to a git repo. These are only intended as samples only, and should not be used in production environments.
To learn more about OneFuse Backups and Policy Restores, the documentation can be found at:
- Install the OneFuse Python Module on the OneFuse appliance.
- Copy the policy_backups.py script to /var/opt/cloudbolt/proserv/onefuse_backups/ on the OneFuse appliance. You will need to create the onefuse_backups directory.
- Create a Connection Info for onefuse. This must be labelled as 'onefuse',
and named 'onefuse'.
- If you are running a dual personality instance where CloudBolt is also installed, you can log in to the CloudBolt UI and create a Connection Info - or use an existing one.
- To do this manually from shell plus ssh in to the OneFuse appliance and then:
python /opt/cloudbolt/manage.py shell_plus ci = ConnectionInfo( name='onefuse', username='<username>', password='<password>', ip='<onefuse fqdn>', port=<port>, protocol='https' ) ci.save() ci.labels.add('onefuse') ci.save()
- Use Git to clone repo to somewhere under /var/opt/cloudbolt/proserv/
cd /var/opt/cloudbolt/proserv/<directory name here if desired> git clone https://<git username>:<git password>@github.com/<repo url>
The backup script will:
- Connect to OneFuse via REST and store all OneFuse Policies in JSON in a local directory
- Use git to synch policies to a git repo
- Update BACKUPS_PATH in the policy_backups.py script to reflect the subdirectory under the folder where you would like backups to end up. This would allow for multiple OneFuse instances to backup to the same git repo. To only backup a single OneFuse instance, GIT_PATH can equal BACKUPS_PATH
- Update GIT_PATH in the policy_backups.py script to reflect the directory where the repo was cloned to
- Update GIT_AUTHOR in the policy_backups.py script to reflect the author information
Execute backups by:
python /var/opt/cloudbolt/proserv/onefuse_backups/policy_backups.py
Restores can now be completed by using the OneFuse Python Module. https://docs.cloudbolt.io/articles/#!onefuse-latest/restore-onefuse-policies-with-onefuse-python-module