Article summary
A while ago I wrote about the Proxmox Backup Client wrapper scripts I use and published to GitHub. Over the weekend, I authored a new Ansible role for installing and configuring the scripts onto a target machine. Here’s what I did and how to use the new role.
The repository, scripts, and Ansible role
The repository with all of the code can be found here. The wrapper scripts are located in the creatively named scripts
directory, while the Ansible role is located within the creatively named ansible
directory.
I will call out that I made this role primarily for myself, which means it follows some conventions that I personally use, but others may not. So while it may not be immediately usable by someone else, I’m publishing this role so that anyone else can beg / borrow / steal as much of it as they’d like for themselves. I encourage you to take and customize to fit whatever your particular needs are.
How to use
How to get
In your own Ansible code, if you want to reference the repository directly, you can add a stanza like the following to your own role requirements file:
- name: pbc_scripts src: https://github.com/fletcherm/pbc-scripts.git scm: git version: 0.3.1
Better yet, download the files to your local Ansible code and configure or repurpose as you need.
Optional (sorta) configuration
When you poke at the defaults/main.yml
file you’ll see there are quite a few knobs to be turned. Most can be left alone, but here are a few of the more interesting ones:. I suspect you’ll need to change at least some of them to be usable for yourself.
pbc_scripts_install_client
Would you like the role to install the Proxmox Backup Client for you? If you’ve installed it yourself, then you can set this to false.pbc_scripts_client_is_arm
: Do you want an ARM version of the Proxmox Backup Client, likely because you’re on a Raspberry Pi? If so, set this to true.pbc_scripts_user
: You will almost certainly need to set this to whatever your Linux username is, unless you happen to use the same name I do.pbc_scripts_src_dir
,pbc_scripts_bin_dir
: These define where the scripts are going to land on your system.pbc_scripts_env_dir
,pbc_scripts_env_file
: These define where the environment file that defines thePBS_*
variables will land. This environment file is something you should source from your main shell login file.pbc_scripts_install_zsh_extension
: If you use zsh and drop extension files into a directory like I do, you can use these variables to ensure zsh loads the appropriate environment files at login.
Required configuration
Some configuration is required when you pull the role into your playbook:
pbc_scripts_backup_dir
: I’ll give you one guess what this is.pbc_scripts_backup_name
: What name these show up under in the Proxmox Backup Server.pbc_scripts_namespace
: What namespace to use in the Proxmox Backup Server.pbc_scripts_repository
: URL to the Proxmox Backup Server instance. You can learn more about the format of this URL in Proxmox’s documentation.
Example usage
Here is an example of how I use this role in one of my own playbooks:
---
- name: Provision decius
hosts: decius.lh
become: true
roles:
- role: ubuntu_noble
- role: ctorgalson.oh-my-zsh
- role: pbc_scripts
vars:
pbc_scripts_backup_dir: "{{ homedir }}/service-data"
pbc_scripts_backup_name: "decius"
pbc_scripts_client_is_arm: true
pbc_scripts_namespace: "lake-house"
pbc_scripts_repository: "fletcher@[email protected]:pbs"
What this does: it backs up the service-data
directory in my home directory to the decius
group under the lake-house
namespace.
Once you’ve provisioned the target machine with this role, you can now run backup-to-pbs.sh
to run the Proxmox Backup Client with all the appropriate configuration. I personally have another wrapper script named backup.sh that does the following:
docker compose down &&
backup-to-pbs.sh &&
docker compose up -d
This stops all the Docker containers as part of this Compose project, backs up the service data, and then restarts the Compose project.
After it runs, the backup will end up showing something like this in Proxmox Backup Server:
Conclusion
Reminder: you will almost certainly need to customize this at least a little bit for yourself. You can use the role directly from my GitHub repository, but don’t be bashful about copying and editing for yourself — there is a good chance this is a bit tailored just for myself. That said, I hope it provides a helpful start for customization for your own Proxmox Backup Client automation.