How to Backup Ansible Updated on November 15, 2021 by InMotion Hosting Contributor 2 Minutes, 44 Seconds to Read Having up-to-date backups is an important part of any Ansible security posture (on Cloud VPS Hosting or otherwise). 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: Git or other Version Control System (VCS)File ArchivalAccount Management Panel (AMP) SnapshotsAnsible Tools 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. Log into your terminalNavigate to the your Ansible root directoryCreate a new git repo: git-initYou can also create repos using GitLab, Github, or another preferred workflow.Add your newly created git repo: git remote add [new-repo-name] [email protected]:[user]/[repo].gitSpecify the files to add to the repo backup: git add --aCommit your changes with a note to on its purpose: git commit -m "Backup XX/XX/XXXX"Push/save your changes: git push [new-repo-name] masterView 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 directorybundle command adds the git repository to a single file for easy archivalgit stash 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: cp command copies files to another directory on the same machinetar command adds files to a new compressed tar file on the same machinezip command adds files to a new compressed zip file on the same machinecron command can run the above commands at scheduled intervals and logs successful cron jobsrsync command can copy and transfer files between machines 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: You cannot extract individual files from a snapshot 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. Share this Article InMotion Hosting Contributor Content Writer InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals! More Articles by InMotion Hosting Related Articles Ansible and Docker What is Ansible? Ansible vs Terraform Getting Started with Ansible How to Install Ansible on a Linux Server WordPress UltraStack Ansible Playbook Tutorial Using Git to Manage your Workflow Ansible Galaxy and Prebuilt Playbooks Accessing your Ansible Control Node How to Backup Ansible