https://github.com/ktooi/ansible-role-argocd-backup
This role is used to deploy a shell script to backup ArgoCD configuration and run it periodically by cron.
https://github.com/ktooi/ansible-role-argocd-backup
ansible ansible-role argocd backup backup-script
Last synced: 2 months ago
JSON representation
This role is used to deploy a shell script to backup ArgoCD configuration and run it periodically by cron.
- Host: GitHub
- URL: https://github.com/ktooi/ansible-role-argocd-backup
- Owner: ktooi
- License: mit
- Created: 2022-06-12T03:11:02.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-10-19T14:01:33.000Z (over 3 years ago)
- Last Synced: 2025-01-14T12:13:43.610Z (over 1 year ago)
- Topics: ansible, ansible-role, argocd, backup, backup-script
- Language: Shell
- Homepage: https://galaxy.ansible.com/ktooi/argocd_backup
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://github.com/ktooi/ansible-role-argocd-backup/actions?query=workflow%3ACI+branch%3Amain)
# Ansible Role: argocd-backup
This role is used to deploy a shell script to backup ArgoCD configuration and run it periodically by cron.
This role does the following
* Install ArgoCD configuration backup scripts.
* Deploy a cron file to run the ArgoCD configuration backup script periodically.
This role does not do the following
* Install ArgoCD.
* Install the `argocd` command.
## Requirements
There are no special requirements for this role.
## How does this backup?
This role will contain the script `backup_argocd.sh` which will backup the ArgoCD configuration.
A dedicated cron file will be placed and `backup_argocd.sh` will be run periodically.
`backup_argocd.sh` works as follows.
* Output configuration information with the `argocd` command (see below for a sample of the `argocd` command that `backup_argocd.sh` executes).
```
argocd -n admin export --kueconfig
```
* If the output configuration information has changed from the previous one, `gzip` it and save it as a backup.
* Update the timestamp in the `watchdog` file when the script completes successfully (a function of `backup_argocd.sh` to monitor normal operation).
## Role Variables
```yaml
argocd_backup_ns: "argocd"
```
Specifies the Namespace where argocd is deployed and whose configuration is to be backed up.
```yaml
argocd_backup_dst_dir: "/var/argocd/backup"
```
Specifies the directory where backups will be stored.
```yaml
argocd_backup_schedule: "0 * * * *"
```
Sets the schedule for performing backups.
Set in cron.d format.
```yaml
argocd_backup_user: root
```
Specifies the user as which backups will be performed.
```yaml
argocd_backup_script_file: "/usr/local/bin/backup_argocd.sh"
```
Specifies the full path of the file to which the backup script will be copied.
```yaml
argocd_backup_cron_file: "/etc/cron.d/argocd-backup"
```
Specifies the full path of the cron file that you want the backup script to run periodically.
```yaml
# argocd_backup_kubeconfig_file:
```
Specify the file (usually `~/.kube/config`) where you store the credentials to connect to Kubernetes.
`argocd_backup_user` must be able to read this file.
This role will not generate or copy the file specified in `argocd_backup_kubeconfig_file`, so you should have credentials in place to connect to Kubernetes in advance.
If `argocd_backup_kubeconfig_file` is not specified, `.kube/config` under `argocd_backup_user` home directory will be specified.
i.e.: `/root/.kube/config`, `/home/ktooi/.kube/config`
```yaml
argocd_backup_become_user_precheck: true
```
This role will perform a precheck before the setup, and whether or not the user specified in ``argocd_backup_user`` should be used for the precheck.
* If set to `true`, the check is performed using the user specified by `argocd_backup_user`. This is a strict check, but you can also specify the user from `ansible_user` to
If you cannot switch from `ansible_user` to `argocd_backup_user`, the check may fail unintentionally.
* If set to `false`, it will promote to the user specified by Ansible, e.g. `ansible_become_user`. This should generally work fine, but is less strict than with `true`.
## Dependencies
None.
## Example Playbook
```yaml
- hosts: argocd_server
roles:
- ktooi.argocd_backup
```
## Authors
* **Kodai Tooi** [GitHub](https://github.com/ktooi), [Qiita](https://qiita.com/ktooi)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details