### Linux Configuration Examples (TOML, YAML, HCL, JSON) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/examples.md Configuration examples for resticprofile on Linux, showing backup and check schedules in TOML, YAML, HCL, and JSON formats. These examples define default settings and specific profiles with custom schedules. ```toml version = "1" [default] password-file = "key" repository = "/tmp/backup" [test1] inherit = "default" [test1.backup] source = "./" schedule = "*:00,15,30,45" schedule-permission = "user" schedule-lock-wait = "15m" [test1.check] schedule = "*-*-1" schedule-permission = "user" schedule-lock-wait = "15m" ``` ```yaml version: "1" default: password-file: key repository: /tmp/backup test1: inherit: default backup: source: ./ schedule: "*:00,15,30,45" schedule-permission: user schedule-lock-wait: 15m check: schedule: "*-*-1" schedule-permission: user schedule-lock-wait: 15m ``` ```hcl "default" = { "password-file" = "key" "repository" = "/tmp/backup" } "test1" = { "inherit" = "default" "backup" = { "source" = "./" "schedule" = "*:00,15,30,45" "schedule-permission" = "user" "schedule-lock-wait" = "15m" } "check" = { "schedule" = "*-*-1" "schedule-permission" = "user" "schedule-lock-wait" = "15m" } } ``` ```json { "version": "1", "default": { "password-file": "key", "repository": "/tmp/backup" }, "test1": { "inherit": "default", "backup": { "source": "./", "schedule": "*:00,15,30,45", "schedule-permission": "user", "schedule-lock-wait": "15m" }, "check": { "schedule": "*-*-1", "schedule-permission": "user", "schedule-lock-wait": "15m" } } } ``` -------------------------------- ### Install resticprofile Binary Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/source.md Install the compiled binary to your user path using the Make install command. ```shell make install ``` -------------------------------- ### Manually install resticprofile using a script Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/macosx.md Download the installation script, make it executable, and run it manually with specific installation options. This provides more control over the installation location. ```shell curl -LO https://raw.githubusercontent.com/creativeprojects/resticprofile/master/install.sh chmod +x install.sh sudo ./install.sh -b /usr/local/bin ``` -------------------------------- ### Systemd Calendar Event Examples Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/configuration.md Examples of user input and their corresponding systemd full format for scheduling. These formats are compatible with macOS and Windows. ```text Sat,Thu,Mon..Wed,Sat..Sun → Mon..Thu,Sat,Sun *-*-* 00:00:00 ``` ```text Mon,Sun 12-*-* 2,1:23 → Mon,Sun 2012-*-* 01,02:23:00 ``` ```text Wed *-1 → Wed *-*-01 00:00:00 ``` ```text Wed..Wed,Wed *-1 → Wed *-*-01 00:00:00 ``` ```text Wed, 17:48 → Wed *-*-* 17:48:00 ``` ```text Wed..Sat,Tue 12-10-15 1:2:3 → Tue..Sat 2012-10-15 01:02:03 ``` ```text *-*-7 0:0:0 → *-*-07 00:00:00 ``` ```text 10-15 → *-10-15 00:00:00 ``` ```text monday *-12-* 17:00 → Mon *-12-* 17:00:00 ``` ```text Mon,Fri *-*-3,1,2 *:30 → Mon,Fri *-*-01,02,03 *:30:00 ``` ```text 12,14,13,12:20,10,30 → *-*-* 12,13,14:10,20,30:00 ``` ```text 12..14:10,20,30 → *-*-* 12..14:10,20,30:00 ``` ```text 03-05 08:05 → *-03-05 08:05:00 ``` ```text 05:40 → *-*-* 05:40:00 ``` ```text Sat,Sun 12-05 08:05 → Sat,Sun *-12-05 08:05:00 ``` ```text Sat,Sun 08:05 → Sat,Sun *-*-* 08:05:00 ``` ```text 2003-03-05 05:40 → 2003-03-05 05:40:00 ``` ```text 2003-02..04-05 → 2003-02..04-05 00:00:00 ``` ```text 2003-03-05 → 2003-03-05 00:00:00 ``` ```text 03-05 → *-03-05 00:00:00 ``` ```text hourly → *-*-* *:00:00 ``` ```text daily → *-*-* 00:00:00 ``` ```text monthly → *-*-01 00:00:00 ``` ```text weekly → Mon *-*-* 00:00:00 ``` ```text yearly → *-01-01 00:00:00 ``` ```text annually → *-01-01 00:00:00 ``` -------------------------------- ### Install Resticprofile via Script Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/linux.md Download and execute the installation script to automatically install resticprofile in the current directory's bin folder. For more control, save the script and run it manually to specify an installation path. ```shell curl -sfL https://raw.githubusercontent.com/creativeprojects/resticprofile/master/install.sh | sh ``` ```shell curl -LO https://raw.githubusercontent.com/creativeprojects/resticprofile/master/install.sh chmod +x install.sh sudo ./install.sh -b /usr/local/bin ``` -------------------------------- ### Systemd Drop-in Configuration Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/systemd.md Example content for a systemd drop-in file, including environment variables for Restic and Rclone credentials. This allows using TPM-backed encrypted passwords. ```conf [Service] Environment=RCLONE_CONFIG=%d/rclone.conf SetCredentialEncrypted=restic-repo-password: \ Whxqht+dQJax1aZeCGLxmiAAAAABAAAADAAAABAAAABl6ctIWEqgRC4yHbgAAAAA8umMn +6KYd8tAL58jUmtf/5wckDcxQSeuo+xd9OzN5XG7QW0iBIRRGCuWvvuAAiHEAKSk9MR8p EDSaSm SetCredentialEncrypted=rclone.conf: \ Whxqht+dQJax1aZeCGLxmiAAAAABAAAADAAAABAAAAC+vNhJYedv5QmyDHYAAAAAimeli +Oo+URGN47SUBf7Jm1n3gdu22+Sd/eL7CjzpYQvHAMOCY8xz9hp9kW9/DstWHTfdsHJo7 thOpk4IbSSazCPwEr39VVQONLxzpRlY22LkQKLoGAVD4Yifk+U5aJJ4FlRW/VGpPoef2S rGvQzqQI7kNX+v7EPXj4B0tSUeBBJJCEu4mgajZNAhwHtbw== ``` -------------------------------- ### Install Resticprofile with Homebrew on Linux Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/linux.md Use Homebrew to install resticprofile. This method also allows for installing restic simultaneously. Ensure restic is installed for testing. ```shell brew tap creativeprojects/tap brew install resticprofile ``` ```shell brew install resticprofile --with-restic ``` ```shell brew test resticprofile ``` -------------------------------- ### Install resticprofile using a script Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/macosx.md Download and execute a script to automatically install the resticprofile binary. This method is suitable for systems where Homebrew is not available or preferred. ```shell curl -sfL https://raw.githubusercontent.com/creativeprojects/resticprofile/master/install.sh | sh ``` -------------------------------- ### Configuration Merging Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/include.md Illustrates how configuration settings are merged when using the 'includes' directive. Later inclusions override earlier definitions. ```yaml version: "1" includes: - first.yaml - second.yaml default: backup: source: - /usr ``` ```yaml version: "1" default: initialize: false backup: source: - /etc - /opt ``` ```yaml version: "1" default: initialize: true backup: exclude: - .* ``` ```yaml version: "1" includes: - first.yaml - second.yaml default: initialize: true backup: exclude: - .* source: - /etc - /opt ``` -------------------------------- ### Install resticprofile with Homebrew Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/macosx.md Add the resticprofile Homebrew tap and install the package. This is the recommended method for easy installation and upgrades. ```shell brew tap creativeprojects/tap brew install resticprofile ``` -------------------------------- ### Backup Configuration with Exclusions (JSON) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Configure backup sources and exclusions using JSON. This example prevents backing up the home directory where the repository is located. ```json { "default": { "repository": "local:${HOME}/backup", "password-file": "${HOME}/backup.key", "backup": { "source": [ "$PWD" ], "exclude": [ "$HOME/**", ".*", "~*" ] } } } ``` -------------------------------- ### Example Output of Run Hooks Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/run_hooks.md This output demonstrates the sequence of run hooks executed during a backup operation, showing messages from profile-level and backup-specific hooks. ```shell ➜ resticprofile documents.backup == run-before profile documents and command backup === run-before backup in profile documents ... processed 355 files, 11.722 MiB in 0:00 snapshot 3949d2fb saved ... === run-after backup in profile documents == run-after profile documents and command backup === run-finally after backup in profile documents == run-finally from profile documents after command backup ``` -------------------------------- ### Example Configuration for Restic Command Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/_index.md Illustrates a complete configuration for the 'backup' command, including repository, password file, verbosity, and source directory, shown in TOML, YAML, HCL, and JSON. ```toml # indentation is not needed but it makes it easier to read ;) # version = "1" [default] repository = "local:/backup" password-file = "password.txt" [default.backup] verbose = true source = [ "/home" ] ``` ```yaml version: "1" default: repository: "local:/backup" password-file: "password.txt" backup: verbose: true source: - "/home" ``` ```hcl default { repository = "local:/backup" password-file = "password.txt" backup = { verbose = true source = [ "/home" ] } } ``` ```json { "version": "1", "default": { "repository": "local:/backup", "password-file": "password.txt", "backup": { "verbose": true, "source": [ "/home" ] } } } ``` -------------------------------- ### Install Resticprofile using Scoop Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/windows.md Install resticprofile using the Scoop package manager. Ensure Scoop is installed and configured. ```powershell scoop install resticprofile ``` -------------------------------- ### Configuration with Variable in JSON Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Example of a JSON configuration using a variable for a USB drive mount point. ```json {{ $mountpoint := "/mnt/external" }} { "version": "1", "global": { "priority": "low" }, "default": { "repository": "local:{{ $mountpoint }}/backup", "password-file": "key", "run-before": "mount {{ $mountpoint }}", "run-after": "umount {{ $mountpoint }}", "run-after-fail": "umount {{ $mountpoint }}", "backup": { "exclude-caches": true, "source": [ "/etc", "/var/lib/libvirt" ], "check-after": true } } } ``` -------------------------------- ### Configuration with Variable in YAML Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Example of a YAML configuration using a variable for a USB drive mount point. ```yaml version: "1" global: priority: low {{ $mountpoint := "/mnt/external" }} default: repository: 'local:{{ $mountpoint }}/backup' password-file: key run-before: 'mount {{ $mountpoint }}' run-after: 'umount {{ $mountpoint }}' run-after-fail: 'umount {{ $mountpoint }}' backup: exclude-caches: true source: - /etc - /var/lib/libvirt check-after: true ``` -------------------------------- ### Backup Configuration with Exclusions (TOML) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Configure backup sources and exclusions using TOML. This example prevents backing up the home directory where the repository is located. ```toml version = "1" [default] repository = "local:${HOME}/backup" password-file = "${HOME}/backup.key" [default.backup] source = "$PWD" exclude = ["$HOME/**", ".*", "~*"] ``` -------------------------------- ### YAML Scheduling Configuration Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/configuration.md Example of a scheduling configuration using YAML format. Demonstrates settings for repository, password file, retention, and backup/prune schedules. ```yaml default: repository: "d:\\backup" password-file: key self: inherit: default retention: after-backup: true keep-within: 14d backup: source: "." schedule: - "Mon..Fri *:00,15,30,45" # every 15 minutes on weekdays - "Sat,Sun 0,12:00" # twice a day on week-ends schedule-permission: user schedule-lock-wait: 10m prune: schedule: "sun 3:30" schedule-permission: user schedule-lock-wait: 1h ``` -------------------------------- ### JSON Configuration Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/getting_started/index.md Example of a resticprofile configuration file in JSON format. Suitable for auto-generated configurations. ```json { "$schema": "{{< absolute "jsonschema/config.json" nohtml >}}", "version": "1", "default": { "repository": "local:/backup", "password-file": "password.txt", "backup": { "verbose": true, "source": [ "/home" ] } } } ``` -------------------------------- ### TOML Configuration Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/getting_started/index.md Example of a resticprofile configuration file in TOML format. Use this for defining backup profiles, repositories, and sources. ```toml #:schema {{< absolute "jsonschema/config-1.json" nohtml >}} # # indentation is not needed but it makes it easier to read ;) # version = "1" [default] repository = "local:/backup" password-file = "password.txt" [default.backup] verbose = true source = [ "/home" ] ``` -------------------------------- ### YAML Configuration Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/getting_started/index.md Example of a resticprofile configuration file in YAML format. This format is human-readable and suitable for defining backup profiles. ```yaml # yaml-language-server: $schema={{< absolute "jsonschema/config.json" nohtml >}} version: "1" default: repository: "local:/backup" password-file: "password.txt" backup: verbose: true source: - "/home" ``` -------------------------------- ### Configuration with Variable in TOML Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Example of a TOML configuration using a variable for a USB drive mount point. ```toml version = "1" [global] priority = "low" {{ $mountpoint := "/mnt/external" }} [default] repository = "local:{{ $mountpoint }}/backup" password-file = "key" run-before = "mount {{ $mountpoint }}" run-after = "umount {{ $mountpoint }}" run-after-fail = "umount {{ $mountpoint }}" [default.backup] exclude-caches = true source = [ "/etc", "/var/lib/libvirt" ] check-after = true ``` -------------------------------- ### Install Resticprofile using Bash Script Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/windows.md Use this script if you are using bash on Windows (e.g., WSL, Git Bash). It downloads the script and executes it, creating a 'bin' directory with the executable. ```shell curl -LO https://raw.githubusercontent.com/creativeprojects/resticprofile/master/install.sh ./install.sh ``` -------------------------------- ### HCL Configuration Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/getting_started/index.md Example of a resticprofile configuration file in HCL format. Useful if you are already using Hashicorp tools. ```hcl default { repository = "local:/backup" password-file = "password.txt" backup = { verbose = true source = [ "/home" ] } } ``` -------------------------------- ### Backup Configuration with Exclusions (YAML) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Configure backup sources and exclusions using YAML. This example prevents backing up the home directory where the repository is located. ```yaml version: "1" default: repository: 'local:${HOME}/backup' password-file: '${HOME}/backup.key' backup: source: '$PWD' exclude: ['$HOME/**', '.*', '~*'] ``` -------------------------------- ### Enable Schedule Start When Available Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/task_scheduler/index.md Use this configuration to ensure that a scheduled task runs as soon as the computer is available, if it was missed due to being asleep or off. This option is equivalent to the 'Start the task as soon as possible after a scheduled start is missed' setting in Windows Task Scheduler. ```yaml profile: backup: schedule: "03:00" schedule-start-when-available: true ``` -------------------------------- ### Install resticprofile via Script Source: https://context7.com/creativeprojects/resticprofile/llms.txt Use the provided script for easy installation on Linux/macOS. Alternatively, download manually and move the binary to your PATH. ```shell # Linux/macOS: use the install script curl -sfL https://raw.githubusercontent.com/creativeprojects/resticprofile/master/install.sh | sh ``` ```shell # Or download manually and make executable wget https://github.com/creativeprojects/resticprofile/releases/latest/download/resticprofile_linux_amd64.tar.gz tar xzf resticprofile_linux_amd64.tar.gz sudo mv resticprofile /usr/local/bin/ ``` ```shell # Verify installation resticprofile version ``` -------------------------------- ### Non-working Template Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/templates.md This TOML configuration uses a Go template that incorrectly defines a retention section, leading to duplicated tables when expanded. ```toml version = "1" {{ define "retention" }} [{{ .Profile.Name }}.retention] after-backup = true before-backup = false compact = false keep-within = "30d" prune = true {{ end }} [src] password-file = "{{ .ConfigDir }}/{{ .Profile.Name }}-key" repository = "/backup/{{ .Now.Weekday }}" lock = "$HOME/resticprofile-profile-{{ .Profile.Name }}.lock" initialize = true [src.backup] source = "{{ .Env.HOME }}/go/src" check-before = true exclude = ["/**/.git"] exclude-caches = true tag = ["{{ .Profile.Name }}", "dev"] {{ template "retention" . }} [src.snapshots] tag = ["{{ .Profile.Name }}", "dev"] [other] password-file = "{{ .ConfigDir }}/{{ .Profile.Name }}-key" repository = "/backup/{{ .Now.Weekday }}" lock = "$HOME/resticprofile-profile-{{ .Profile.Name }}.lock" initialize = true {{ template "retention" . }} ``` -------------------------------- ### Dry Run Command Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/_index.md Demonstrates how to perform a dry run of the 'backup' command using resticprofile to preview the generated restic command without execution. ```shell resticprofile --dry-run backup 2022/05/18 17:14:07 profile 'default': starting 'backup' 2022/05/18 17:14:07 dry-run: /usr/bin/restic backup --password-file password.txt --repo local:/backup --verbose /home 2022/05/18 17:14:07 profile 'default': finished 'backup' ``` -------------------------------- ### Configuration with Variable in HCL Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Example of an HCL configuration using a variable for a USB drive mount point. ```hcl global { priority = "low" } {{ $mountpoint := "/mnt/external" }} default { repository = "local:{{ $mountpoint }}/backup" password-file = "key" run-before = "mount {{ $mountpoint }}" run-after = "umount {{ $mountpoint }}" run-after-fail = "umount {{ $mountpoint }}" backup { exclude-caches = true source = [ "/etc", "/var/lib/libvirt" ] check-after = true } } ``` -------------------------------- ### Install Shell Completions Permanently Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/shell.md These commands install shell completions for bash and fish permanently. Ensure you have the necessary permissions to write to the specified directories. ```shell resticprofile generate --bash-completion > /etc/bash_completion.d/resticprofile chmod +x /etc/bash_completion.d/resticprofile ``` ```shell resticprofile generate --fish-completion > /etc/fish/completions/resticprofile.fish chmod +x /etc/fish/completions/resticprofile.fish ``` -------------------------------- ### Complex Configuration with Inheritance (TOML) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/examples.md Demonstrates advanced resticprofile configuration with global settings, groups, profile inheritance, and detailed backup/retention policies. This example uses TOML format. ```toml version = "1" [global] # ionice is available on Linux only ionice = false ionice-class = 2 ionice-level = 6 # priority is using priority class on windows, and "nice" on unixes priority = "low" # run 'snapshots' when no command is specified when invoking resticprofile default-command = "snapshots" # initialize a repository if none exist at location initialize = false # resticprofile won't start a profile if there's less than 100MB of RAM available min-memory = 100 # a group is a profile that will call all profiles one by one [groups] # when starting a backup on profile "full-backup", # it will run the "root" and "src" backup profiles full-backup = [ "root", "src" ] # Default profile when not specified on the command line (-n or --name) # There's no default inheritance from the 'default' profile, # you can use the 'inherit' flag if needed [default] # you can use a relative path, it will be relative to the configuration file repository = "/backup" password-file = "key" initialize = false # will run these scripts before and after each command (including 'backup') run-before = "mount /backup" run-after = "umount /backup" # if a restic command fails, the run-after won't be running # add this parameter to run the script in case of a failure run-after-fail = "umount /backup" # add environment variables [default.env] TMPDIR= "/tmp" # New profile named 'root' [root] inherit = "default" initialize = true # LOCAL lockfile so you cannot run the same profile more than once at a time # (it's totally independent of the restic locks on the repository) lock = "/tmp/resticprofile-root.lock" # 'backup' command of profile 'root' [root.backup] # files with no path are relative to the configuration file exclude-file = [ "root-excludes", "excludes" ] exclude-caches = true one-file-system = false tag = [ "test", "dev" ] source = [ "/" ] # ignore restic warnings when files cannot be read no-error-on-warning = true # run every day at midnight schedule = "daily" schedule-permission = "system" schedule-lock-wait = "2h" # retention policy for profile root # retention is a special section that run the "forget" command # before or after a backup [root.retention] before-backup = false after-backup = true keep-hourly = 1 keep-daily = 1 keep-weekly = 1 keep-monthly = 1 keep-within = "3h" keep-tag = [ "forever" ] prune = false # tag can be a boolean ('true' meaning to copy tag set from 'backup') # or a custom set of tags. # Default is 'false', meaning that tags are NOT used. tag = true # host can be a boolean ('true' meaning current hostname) # or a string to specify a different hostname host = true ``` -------------------------------- ### JSON Scheduling Configuration Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/configuration.md Example of a scheduling configuration using JSON format. Includes repository, password file, retention, and backup/prune schedules. ```json { "default": { "repository": "d:\\backup", "password-file": "key" }, "self": { "inherit": "default", "retention": { "after-backup": true, "keep-within": "14d" }, "backup": { "source": ".", "schedule": [ "Mon..Fri *:00,15,30,45", "Sat,Sun 0,12:00" ], "schedule-permission": "user", "schedule-lock-wait": "10m" }, "prune": { "schedule": "sun 3:30", "schedule-permission": "user", "schedule-lock-wait": "1h" } } } ``` -------------------------------- ### TOML Scheduling Configuration Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/configuration.md Example of a scheduling configuration using TOML format. Includes settings for repository, password file, retention policies, and backup/prune schedules. ```toml [default] repository = "d:\\backup" password-file = "key" [self] inherit = "default" [self.retention] after-backup = true keep-within = "14d" [self.backup] source = "." schedule = [ "Mon..Fri *:00,15,30,45", "Sat,Sun 0,12:00" ] schedule-permission = "user" schedule-lock-wait = "10m" [self.prune] schedule = "sun 3:30" schedule-permission = "user" schedule-lock-wait = "1h" ``` -------------------------------- ### Backup Configuration with Exclusions (HCL) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Configure backup sources and exclusions using HCL. This example prevents backing up the home directory where the repository is located. ```hcl default { repository = "local:${HOME}/backup" password-file = "${HOME}/backup.key" backup { source = [ "$PWD" ] exclude = [ "$HOME/**", ".*", "~*" ] } } ``` -------------------------------- ### Configuration File Structure (TOML) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/path.md Example of a resticprofile configuration file in TOML format, demonstrating default settings and backup source configuration. ```toml # indentation is not needed but it makes it easier to read ;) # version = "1" [default] base-dir = "" repository = "local:backup" password-file = "password.txt" [default.backup] source-base = "" source = [ "files" ] ``` -------------------------------- ### Example Output of Command Hooks Source: https://context7.com/creativeprojects/resticprofile/llms.txt Illustrates the expected output when running a resticprofile command with configured profile-level and section-level hooks. Shows the execution order and variable substitution. ```shell resticprofile documents.backup # == starting backup for documents # === mounting backup disk # ... restic output ... # snapshot 3949d2fb saved # === unmounting backup disk # == finished backup for documents # === backup section cleanup # == cleanup always runs ``` -------------------------------- ### Example Generated Status File Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/monitoring/status.md This JSON output shows the results of the last 'check' command failing and the last 'backup' command succeeding. ```json { "profiles": { "self": { "backup": { "success": true, "time": "2021-03-24T16:36:56.831077Z", "error": "", "stderr": "", "duration": 16, "files_new": 215, "files_changed": 0, "files_unmodified": 0, "dirs_new": 58, "dirs_changed": 0, "dirs_unmodified": 0, "files_total": 215, "bytes_added": 296536447, "bytes_total": 362952485 }, "check": { "success": false, "time": "2021-03-24T15:23:40.270689Z", "error": "exit status 1", "stderr": "unable to create lock in backend: repository is already locked exclusively by PID 18534 on dingo by cloud_user (UID 501, GID 20)\nlock was created at 2021-03-24 15:23:29 (10.42277s ago)\nstorage ID 1bf636d2\nthe `unlock` command can be used to remove stale locks\n", "duration": 1 } } } } ``` -------------------------------- ### HCL Scheduling Configuration Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/configuration.md Example of a scheduling configuration using HCL format. Shows settings for repository, password file, retention, and backup/prune schedules. ```hcl "default" = { "repository" = "d:\\backup" "password-file" = "key" } "self" = { "inherit" = "default" "retention" = { "after-backup" = true "keep-within" = "14d" } "backup" = { "source" = "." "schedule" = ["Mon..Fri *:00,15,30,45", "Sat,Sun 0,12:00"] "schedule-permission" = "user" "schedule-lock-wait" = "10m" } "prune" = { "schedule" = "sun 3:30" "schedule-permission" = "user" "schedule-lock-wait" = "1h" } } ``` -------------------------------- ### Configuration File Structure (YAML) Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/path.md Example of a resticprofile configuration file in YAML format, showcasing default settings and backup source configuration. ```yaml version: "1" default: base-dir: "" repository: "local:backup" password-file: "password.txt" backup: source-base: "" source: - "files" ``` -------------------------------- ### Restic Profile Configuration with Templates Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/templates.md Example of a restic profile configuration ('nas-root') that inherits from a 'nas' profile and includes the 'backup_root' template for specific backup settings. ```json "nas-root" = { "inherit" = "nas" "backup" = { # get the content of "backup_root" defined at the top {{ template "backup_root" . }} "schedule" = "01:47" "schedule-permission" = "system" "schedule-log" = "{{ .Profile.Name }}-backup.log" } } ``` -------------------------------- ### Example Variable Expansion in Configuration Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md This YAML snippet demonstrates variable expansion for profile tags and source directories using Go templating syntax. It shows how to dynamically set values based on profile names and environment variables. ```yaml { "dev" ] } }, "snapshots": { "tag": [ "{{ .Profile.Name }}", "dev" ] } }, "src": { "inherit": "generic", "backup": { "source": [ "{{ .Env.HOME }}/go/src" ] }, "check": { "read-data-subset": "{{ len (printf "a%*s" .Now.Weekday "") }}/7" } } } ``` -------------------------------- ### Run Resticprofile Container with Mounted Configuration Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/docker.md This command runs the resticprofile container, mounting the local 'examples' directory to '/resticprofile' inside the container. This is useful for feeding configuration files to the container. ```shell docker run -it --rm -v $PWD/examples:/resticprofile ghcr.io/creativeprojects/resticprofile ``` -------------------------------- ### Backup Using Alternative Syntax Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/usage/_index.md Execute a backup using the alternative `profile.command` syntax. This is a shorthand for specifying both the profile and the command. ```shell resticprofile full-backup.backup ``` -------------------------------- ### Test resticprofile installation with Homebrew Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/macosx.md Verify that resticprofile is installed correctly using the Homebrew test command. This requires restic to be installed separately. ```shell brew test resticprofile ``` -------------------------------- ### Install resticprofile with Homebrew and Restic Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/macosx.md Install resticprofile using Homebrew, including restic as a dependency. This option ensures both tools are installed together. ```shell brew install resticprofile --with-restic ``` -------------------------------- ### Install GCC for Homebrew on Linux Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/linux.md When installing resticprofile via Homebrew on new Linux virtual machines, a compiler like GCC may be required. Install GCC using your distribution's package manager. ```shell sudo yum install gcc ``` ```shell sudo apt install gcc ``` -------------------------------- ### TOML Configuration for Run Hooks Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/run_hooks.md Example of configuring global and specific run hooks using TOML format. Supports commands before, after, on failure, and finally for profile-wide operations and specific backup commands. ```toml version = "1" [documents] run-before = 'echo "== run-before profile $PROFILE_NAME and command $PROFILE_COMMAND"' run-after = 'echo "== run-after profile $PROFILE_NAME and command $PROFILE_COMMAND"' run-after-fail = 'echo "== ERROR in profile $PROFILE_NAME command ${PROFILE_COMMAND}: $ERROR_MESSAGE"' run-finally = 'echo "== run-finally from profile $PROFILE_NAME after command $PROFILE_COMMAND"' [documents.backup] run-before = 'echo "=== run-before backup in profile $PROFILE_NAME"' run-after = 'echo "=== run-after backup in profile $PROFILE_NAME"' run-after-fail = 'echo "=== ERROR in backup for profile ${PROFILE_NAME}: $ERROR_MESSAGE"' run-finally = 'echo "=== run-finally after backup in profile $PROFILE_NAME"' source = "~/Documents" ``` -------------------------------- ### Install Resticprofile using Winget Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/installation/windows.md Install resticprofile using Winget, the Windows Package Manager. This is suitable for Windows 10 and 11. ```powershell winget install creativeprojects.resticprofile ``` -------------------------------- ### Mixin Declaration and Usage Example Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/inheritance.md Demonstrates how to declare named mixins and use them within profile configurations. This includes setting default variables, overriding configuration keys, and appending to list properties. ```yaml version: 2 mixins: alternate-repository: repository: local:/backup/alternate password-file: alternate-repo.key retain-last: default-vars: LAST: 30 retention: keep-last: $LAST keep-hourly: false keep-daily: false keep-weekly: false exclude-backup: exclude...: - "/backup/*" - "*.bak*" exclude-hidden: exclude...: - "*." - "*~" profiles: select-some-and-retain-last-30: use: - alternate-repository - retain-last backup: use: - exclude-backup - exclude-hidden exclude: /tmp source: / select-all-and-retain-last-60: use: - alternate-repository - name: retain-last LAST: 60 backup: source: / ``` ```toml version = 2 [mixins] [mixins.alternate-repository] repository = "local:/backup/alternate" password-file = "alternate-repo.key" [mixins.retain-last] default-vars = { LAST = 30 } [mixins.retain-last.retention] keep-last = "$LAST" keep-hourly = false keep-daily = false keep-weekly = false [mixins.exclude-backup] exclude__APPEND = [ "/backup/*", "*.bak*", ] [mixins.exclude-hidden] exclude__APPEND = [ "*.", "*~", ] [profiles] [profiles.select-some-and-retain-last-30] use = ["alternate-repository", "retain-last"] [profiles.some-keep-last-30.backup] use = ["exclude-backup", "exclude-hidden"] exclude = "/tmp" source = "/" [profiles.select-all-and-retain-last-60] use = [ "alternate-repository", { name = "retain-last", LAST = 60 }, ] [profiles.select-all-and-retain-last-60.backup] source = "/" ``` -------------------------------- ### YAML Configuration for Run Hooks Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/run_hooks.md Example of configuring global and specific run hooks using YAML format. Supports commands before, after, on failure, and finally for profile-wide operations and specific backup commands. ```yaml version: "1" documents: run-before: 'echo "== run-before profile $PROFILE_NAME and command $PROFILE_COMMAND"' run-after: 'echo "== run-after profile $PROFILE_NAME and command $PROFILE_COMMAND"' run-after-fail: 'echo "== ERROR in profile $PROFILE_NAME command ${PROFILE_COMMAND}: $ERROR_MESSAGE"' run-finally: 'echo "== run-finally from profile $PROFILE_NAME after command $PROFILE_COMMAND"' backup: run-before: 'echo "=== run-before backup in profile $PROFILE_NAME"' run-after: 'echo "=== run-after backup in profile $PROFILE_NAME"' run-after-fail: 'echo "=== ERROR in backup for profile ${PROFILE_NAME}: $ERROR_MESSAGE"' run-finally: 'echo "=== run-finally after backup in profile $PROFILE_NAME"' source: ~/Documents ``` -------------------------------- ### Start a Resticprofile Backup Manually Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/launchd.md Use this command to manually start a backup profile named 'remote' managed by resticprofile via launchd. ```shell /bin/launchctl start local.resticprofile.remote.backup ``` -------------------------------- ### Include Multiple Configuration Files Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/include.md Demonstrates how to use the 'includes' directive to load configurations from multiple files and glob patterns in TOML, YAML, HCL, and JSON formats. ```toml version = "1" # Includes includes = ["conf.d/*.conf", "profiles.d/*.yaml", "profiles.d/*.toml"] # Defaults [global] initialize = true ``` ```yaml version: "1" includes: - "conf.d/*.conf" - "profiles.d/*.yaml" - "profiles.d/*.toml" global: initialize: true ``` ```hcl includes = ["conf.d/*.conf", "profiles.d/*.yaml", "profiles.d/*.toml"] global { initialize = true } ``` ```json { "version": "1", "includes": [ "conf.d/*.conf", "profiles.d/*.yaml", "profiles.d/*.toml" ], "global": { "initialize": true } } ``` -------------------------------- ### Minimal resticprofile Configuration Source: https://context7.com/creativeprojects/resticprofile/llms.txt Define a basic profile in YAML format, including repository, password file, and backup source. This example also shows commands for generating a password file, initializing the repository, and performing a dry-run or actual backup. ```yaml # profiles.yaml # yaml-language-server: $schema=https://creativeprojects.github.io/resticprofile/jsonschema/config.json version: "1" default: repository: "local:/backup" password-file: "password.txt" backup: verbose: true source: - "/home" ``` ```shell # Generate a secure password file resticprofile generate --random-key > password.txt ``` ```shell # Initialize the repository resticprofile init # 2023/03/25 15:46:48 profile 'default': starting 'init' # created restic repository e21ab75046 at local:/backup ``` ```shell # Dry-run to preview the generated restic command resticprofile --dry-run backup # dry-run: /usr/local/bin/restic backup --password-file password.txt --repo local:/backup --verbose /home ``` ```shell # Run the actual backup resticprofile backup ``` -------------------------------- ### Example Prometheus Metrics Output Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/monitoring/prometheus.md This is an example of the metrics file generated by Resticprofile when Prometheus integration is enabled. It includes build information, backup statistics, and status. ```text # HELP restic_build_info restic build information. # TYPE restic_build_info gauge restic_build_info{profile="prom",version="0.18.0"} 1 # HELP resticprofile_backup_added_bytes Total number of bytes added to the repository. # TYPE resticprofile_backup_added_bytes gauge resticprofile_backup_added_bytes{profile="prom"} 96167 # HELP resticprofile_backup_dir_changed Number of directories with changes. # TYPE resticprofile_backup_dir_changed gauge resticprofile_backup_dir_changed{profile="prom"} 8 # HELP resticprofile_backup_dir_new Number of new directories added to the backup. # TYPE resticprofile_backup_dir_new gauge resticprofile_backup_dir_new{profile="prom"} 0 # HELP resticprofile_backup_dir_unmodified Number of directories unmodified since last backup. # TYPE resticprofile_backup_dir_unmodified gauge resticprofile_backup_dir_unmodified{profile="prom"} 1060 # HELP resticprofile_backup_duration_seconds The backup duration (in seconds). # TYPE resticprofile_backup_duration_seconds gauge resticprofile_backup_duration_seconds{profile="prom"} 0.986296416 # HELP resticprofile_backup_files_changed Number of files with changes. # TYPE resticprofile_backup_files_changed gauge resticprofile_backup_files_changed{profile="prom"} 2 # HELP resticprofile_backup_files_new Number of new files added to the backup. # TYPE resticprofile_backup_files_new gauge resticprofile_backup_files_new{profile="prom"} 0 # HELP resticprofile_backup_files_processed Total number of files scanned by the backup for changes. # TYPE resticprofile_backup_files_processed gauge resticprofile_backup_files_processed{profile="prom"} 7723 # HELP resticprofile_backup_files_unmodified Number of files unmodified since last backup. # TYPE resticprofile_backup_files_unmodified gauge resticprofile_backup_files_unmodified{profile="prom"} 7721 # HELP resticprofile_backup_processed_bytes Total number of bytes scanned for changes. # TYPE resticprofile_backup_processed_bytes gauge resticprofile_backup_processed_bytes{profile="prom"} 2.935621558e+09 # HELP resticprofile_backup_status Backup status: 0=fail, 1=warning, 2=success. # TYPE resticprofile_backup_status gauge resticprofile_backup_status{profile="prom"} 2 # HELP resticprofile_backup_time_seconds Last backup run (unixtime). # TYPE resticprofile_backup_time_seconds gauge resticprofile_backup_time_seconds{profile="prom"} 1.747673785e+09 # HELP resticprofile_build_info resticprofile build information. # TYPE resticprofile_build_info gauge resticprofile_build_info{goversion="go1.24.3",profile="prom",version="0.31.0"} 1 ``` -------------------------------- ### Manually start a resticprofile task on macOS Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/schedules/examples.md Manually starts a resticprofile task using its service name obtained from the status command. This is often necessary to grant permissions for network or volume access. ```shell % launchctl start local.resticprofile.azure-dev.backup ``` -------------------------------- ### Accessing Environment Variables Source: https://github.com/creativeprojects/resticprofile/blob/master/docs/content/configuration/variables.md Shows how to access environment variables using the `.Env.` prefix. This allows for dynamic configuration based on the execution environment. ```go-template {{ .Env.HOME }} ``` ```go-template {{ .Env.USERPROFILE }} ``` -------------------------------- ### Example Prometheus metrics file content Source: https://context7.com/creativeprojects/resticprofile/llms.txt Illustrates the format and types of metrics exported to a Prometheus file. ```text # HELP resticprofile_backup_status Backup status: 0=fail, 1=warning, 2=success. resticprofile_backup_status{profile="root",host="myserver",environment="production"} 2 # HELP resticprofile_backup_duration_seconds The backup duration (in seconds). resticprofile_backup_duration_seconds{profile="root",...} 0.986 # HELP resticprofile_backup_files_new Number of new files added to the backup. resticprofile_backup_files_new{profile="root",...} 0 # HELP resticprofile_backup_added_bytes Total number of bytes added to the repository. resticprofile_backup_added_bytes{profile="root",...} 96167 ```