How to Backup Ansible

Having up-to-date backups is an important part of any Ansible security posture. If your Ansible control machine (server or local machine) suffers a cyber attack, sometimes the best option is to restore an Ansible backup file.

There are multiple ways to manage Ansible playbook backups:

Need a web server without cPanel? Check out our high-availability Cloud VPS Hosting.

Git Commands

The best method for backing up Ansible is with git or a similar version control system (VCS), which creates a repository with a full list of changes. Below are the steps for all Git-based workflows.

  1. Log into your terminal
  2. Navigate to the your Ansible root directory
  3. Create a new git repo: git-init

    You can also create repos using GitLab, Github, or another preferred workflow.

  4. Add your newly created git repo: git remote add [new-repo-name] git@github.com:[user]/[repo].git
  5. Specify the files to add to the repo backup: git add --a
  6. Commit your changes with a note to on its purpose: git commit -m "Backup XX/XX/XXXX"
  7. Push/save your changes: git push [new-repo-name] master
  8. View all archived repos: git remote -v

There are other ways to quickly duplicate your Ansible git repositories:

  • clone command copies the entire git repository to a new directory
  • bundle command adds the git repository to a single file for easy archival

CLI Commands

Operating systems have native commands to copy files and directories.

Unix Commands

There are many CLI commands to create backups on Linux, MacOS, and other Unix-based systems:

Windows Commands

The Windows copy command copies files to another directory on the same machine.

External Tools

AWS Command Line Interface (CLI) is an open source tool for connecting your local machine or server to your Amazon S3 cloud storage. You can schedule and restore backups among other features with AWS CLI commands.

Focus on your mission and have our Managed Hosting team configure AWS CLI on your VPS or Dedicated server with Launch Assist.

Google Cloud FUSE is an open source FUSE adapter that connects your Dedicated server to a Google Cloud Bucket.

Snapshots

An AMP Snapshot is a copy of all data on the server. It doesn’t affect server disk space. It’s an important last resort for hack recovery, especially if other backups are compromised or out of date. Server snapshots can easily be configured for automated Ansible playbook backups.

The differences between snapshots and other backup methods:

  1. You cannot extract individual files from a snapshot 
  2. You cannot export snapshots from AMP

Ansible Tools

Ansible backup modules can be run separately or within playbooks such as copy and product-specific modules for Cisco ACI, Avi Networks, VMware, and more.

Ansible Galaxy includes community-sourced collections and roles if you wish to use Ansible for backups. This is essential if you’re also using Ansible for security improvements.

The Ansible Tower web console natively includes backup options.

Follow our Ansible Education Channel for more on IT automation.

Was this article helpful? Let us know!