creativeprojects / resticprofile

Configuration profiles manager and scheduler for restic backup
https://creativeprojects.github.io/resticprofile/
GNU General Public License v3.0
710 stars 33 forks source link

Volume Name #156

Open FriedrichHSRT opened 1 year ago

FriedrichHSRT commented 1 year ago

Hello, would be nice, if the windows version would be able to use volume names for target instead of driveletters (who can change).

cu F. :-)

jkellerer commented 1 year ago

Would you mind running resticprofile --dry-run your-profile.backup and post the output in here so that we can see if the problem is related to passing of command line flags.

FriedrichHSRT commented 1 year ago

Hello, maybe a misunderstanding, I would like to have the feature to replace the drive letter with the volume name (because the drive letter can change). cu F. :-)

jkellerer commented 1 year ago

Ok, think I understand your request, you are referring to a solution like this:

version: "2"

includes:
  - "volumes.conf"

# defaults to satisfy "use" when "volumes.conf" is missing
mixins:
  source_my_system_drive: {}

global:
  initialize: true
  shell: powershell

profiles:
  default:
    repository: "local:test-repo"
    password-file: "password.txt"
    run-before: 
      - echo "" | Out-File -Encoding ASCII "{{.ConfigDir}}/volumes.conf"
      - >-
        Get-WmiObject Win32_Volume
        | where Label
        | % { "[mixins.source_{0}]`r`n source__APPEND='{1}{2}path'" -f ($_.Label -replace "\s", "_").ToLower(), ($_.Name -replace "\\", "/"), '$' }
        | Out-File -Encoding ASCII -Append "{{.ConfigDir}}/volumes.conf"

  system:
    inherit: default
    backup:
      use:
        - name: source_my_system_drive
          path: files/to/backup
        - name: source_my_system_drive
          path: other-files/to/backup
      tag: my-tag

resticprofile.exe --quiet stats
scanning...
Stats in restore-size mode:
Snapshots processed:   0
         Total Size:   0 B

resticprofile.exe --dry-run system.backup
...
2022/12/27 16:34:46 dry-run: C:\Windows\system32\restic.exe backup --password-file password.txt --repo local:test-repo --tag my-tag C:/files/to/backup C:/other-files/to/backup
...

(Assuming C:\ has a label of My System Drive)


Dynamically creating configuration from script is currently not supported explicitly, therefore an initial stats call (or similar) is required to build volumes.conf.

Translating volume labels to paths is a quite specific request. Maybe we can simplify using scripts inside the configuration to build values dynamically instead. The workaround from above should work in the meantime.