Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Variables in schedule-log only parsed during scheduling of backup jobs #338

Open
ThelloD opened this issue Mar 12, 2024 · 2 comments
Open
Labels
enhancement New feature or request
Milestone

Comments

@ThelloD
Copy link

ThelloD commented Mar 12, 2024

Summary

The schedule-log parameter in my profile contains variables, for including the date in the log file name (e.g. {{ .Now.Format "2006-01-02" }}). Unfortunately, this variable is parsed during creation of the scheduled backup job, and not every time the scheduled job is executed. Therefore, the name of the log file will include the date when the scheduled job was created, and not the actual execution time stamp.

Question/Issue

Is it possible to parse variables during runtime of the backup job, instead of the time where the backup job was scheduled?

Details

Let's assume my profiles.yaml file is as follows:

version: "2"
profiles:
  myprofile:
    repository: ~/backups/data/{{ .Profile.Name }}

    backup:
      files-from: 
        - ... (cut for brevity)
      tag:
        - mytag
      schedule:
        - "Mon..Fri 17:45"
      schedule-permission: user
      schedule-log: ~/backups/logs/schedule-{{ .Profile.Name }}-{{ .Now.Format "2006-01-02" }}.log

Let's assume I executed resticprofile -n myprofile schedule on March 1, 2024. On Windows, this would create the following scheduled task:

Application: C:\...\resticprofile.exe
Arguments: --no-ansi --config C:\...\profiles.yaml --name mytag --log C:\Users\USERNAME/backups/logs/schedule-myprofile-2024-03-01.log backup

Therefore, the "data" variable in for the --log is lost and replaced by a static value, namely 2024-03-01. Consequently, if the backup job is executed later on, e.g. on April 15, the log file will still remain schedule-myprofile-2024-03-01.log.

@jkellerer
Copy link
Collaborator

Thanks a lot for the detailed report. This will be fixed in #259 where schedules are no longer rendered to a full command line at creation time.

@creativeprojects
Copy link
Owner

I haven't thought about this case before, but this is indeed a good use of the new run-schedule command 😄

@creativeprojects creativeprojects added this to the v0.27.0 milestone Mar 12, 2024
@creativeprojects creativeprojects added the enhancement New feature or request label Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants