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

Prune error when using forget: yes #297

Open
ilium007 opened this issue Mar 24, 2023 · 10 comments
Open

Prune error when using forget: yes #297

ilium007 opened this issue Mar 24, 2023 · 10 comments
Labels
bug Something isn't working

Comments

@ilium007
Copy link

ilium007 commented Mar 24, 2023

Describe the bug
The example config has this option for 'forget':
forget: prune # Or only "yes" if you don't want to prune

If I try:
forget: yes

I get the error below:
invalid value for forget option: 1 Error: 1 errors were found

The below works fine:
forget: prune # Or only "yes" if you don't want to prune

Expected behavior
Forget should run without pruning

Environment
Debian 11

@cupcakearmy
Copy link
Owner

Interesting, could you try forget: "yes" (with the quotes)

@ilium007
Copy link
Author

That worked. So why does prune not need the quotes?

@cupcakearmy cupcakearmy added the bug Something isn't working label Mar 25, 2023
@cupcakearmy
Copy link
Owner

Because the yaml library used here interprets the yes as true Probably should handle the case.

@pquerner
Copy link

pquerner commented Mar 23, 2024

I have "forget" to "prune" in backup command. But I get this error:

backends:
  pcloud2:
    type: rclone
    path: pcloud2:restic_test4
    key: 123
    env: {}
    rest:
      user: ""
      password: ""
    options:
      backup:
        option:
        - rclone.args=serve restic --stdio --verbose
        - rclone.program=/var/services/homes/pascal/rclone
extras:
  log:
    hooks:
      before:
      - 'echo "Starting backup for location: ${AUTORESTIC_LOCATION}"'
      failure:
      - 'echo "Backup failed for location: ${AUTORESTIC_LOCATION}"'
      success:
      - 'echo "Backup successful for location: ${AUTORESTIC_LOCATION}"'
locations:
  projects:
    forget: prune
    from:
    - "/xxx/downloads"
    type: ""
    to:
    - pcloud2
    hooks:
      dir: ""
      prevalidate: []
      before: []
      after: []
      success: []
      failure: []
    cron: ""
    options:
      forget:
        keep-last: 5
      backup:
        exclude:
        - node_modules
        - .git
    copyoption: {}
version: 2

./autorestic_1.8.1_linux_amd64 --verbose -c ./autorestic_configs/autorestic.config.yml --restic-bin $HOME/restic_0.16.4_linux_amd64 backup -a
Using config: 	 /var/services/homes/pascal/autorestic_configs/autorestic.config.yml
Using lock:	 autorestic_configs/.autorestic.lock.yml


    Backing up location "projects"

Backend: pcloud2
> Executing: /var/services/homes/pascal/restic_0.16.4_linux_amd64 backup --option rclone.args=serve restic --stdio --verbose --option rclone.program=/var/services/homes/pascal/rclone --exclude node_modules --exclude .git --tag ar:location:projects /xxx/downloads/
no parent snapshot found, will read all files


Files:           1 new,     0 changed,     0 unmodified
Dirs:            4 new,     0 changed,     0 unmodified
Added to the repository: 1.201 GiB (1.197 GiB stored)

processed 1 files, 1.201 GiB in 4:18
snapshot 03bc4d1c saved


  Forgetting for location "projects"

For backend "pcloud2"
> Executing: /var/services/homes/pascal/restic_0.16.4_linux_amd64 forget --tag ar:location:projects --prune --keep-last 5
exit status 1

Error: 1 errors were found
pascal@Honeycomb:~$
pascal@Honeycomb:~$ /var/services/homes/pascal/restic_0.16.4_linux_amd64 forget --tag ar:location:projects --prune --keep-last 5
Fatal: Please specify repository location (-r or --repository-file)

@LM1LC3N7
Copy link

LM1LC3N7 commented Jun 11, 2024

Hi,

I also have a problem with prune option. Right after the backup log, there is the "forgetting" part and always in error like that:

  Forgetting for location "discourse"

For backend "backblaze"
> Executing: /usr/local/bin/restic forget --tag ar:location:discourse --prune --keep-last 5 --keep-monthly 2 --keep-hourly 0 --keep-yearly 0 --keep-weekly 2 --keep-daily 4
repo already locked, waiting up to 0s for the lock
exit status 1

Config extract:

---
version: 2

extras:
  hooks: &telegram
    before:
      - /home/lmilcent/admin/restic/telegram/start.sh
    failure:
      - /home/lmilcent/admin/restic/telegram/error.sh
    success:
      - /home/lmilcent/admin/restic/telegram/success.sh

#
# Global Config
#
global:
  forget:
    keep-last: 5      # always keep at least 5 snapshots
    keep-daily: 4     # keep 4 last daily snapshots
    keep-weekly: 2    # keep 4 last weekly snapshots
    keep-monthly: 2   # keep 6 last monthly snapshot
    keep-yearly: 0    # keep 1 last yearly snapshot
    keep-hourly: 0    # keep 3 last hourly snapshots
    #keep-within: '2w' # keep snapshots

locations:
  home:
    from:
      - /home
    to:
      - backblaze
    cron: '0 0 * * *' # Every days at 00:00 (incremental snapshots)
    forget: "prune"
    # Hooks defined in default on top of file
    hooks:
      <<: *telegram
    options:
      backup:
        tag: home
        exclude:
          - .cache/
          - .autorestic.lock.yml
          - .local/

@FunctionDJ
Copy link

FunctionDJ commented Jun 17, 2024

I have the same issue with an SFTP backend:

$ autorestic forget -av
Using config paths: . /home/function /home/function/.config/autorestic
Using config:    /home/function/.autorestic.yml
Using lock:      /home/function/.autorestic.lock.yml


  Forgetting for location "data"  

For backend "truenas"
> Executing: /usr/local/bin/restic forget --tag ar:location:data --keep-yearly 4 --keep-monthly 4 --keep-daily 4 --keep-weekly 4
repo already locked, waiting up to 0s for the lock
Error: exit status 1

I tried autorestic unlock which didn't show any error but didn't fix the issue so i think a repo lock is not the issue.

Edit: restic unlock appears to have fixed the issue. Not sure why autorestic unlock didn't fix it.

@pew
Copy link

pew commented Jun 17, 2024

@FunctionDJ I had the same issue and tried autorestic unlock with no success, however autorestic exec -b my-backend -- unlock fixed it. Looks like the first unlock command handles a running restic process on the system, and the latter actually unlocks the remote repoistory.

@FunctionDJ
Copy link

@pew wow if i had known about autorestic exec that would saved me a bunch of typing and pasting.

i wonder why the two behave differently. i assumed autorestic unlock is supposed to do at least the same as restic unlock.

@LM1LC3N7
Copy link

@FunctionDJ I had the same issue and tried autorestic unlock with no success, however autorestic exec -b my-backend -- unlock fixed it. Looks like the first unlock command handles a running restic process on the system, and the latter actually unlocks the remote repoistory.

Thanks for the workaround!
It saved me more than 1.2Tb of backup data. From 1.7Tb to 290Gb stored! My backblaze billing was growing and I did not understand why, as the forget option in autorestic was enabled.

I hope this bug will be solved soon, or this is just an "historic" issue, as I am using autorestic for years now. Thanks @cupcakearmy for the tool, I absolutely love ❤️

@ilium007
Copy link
Author

I was also getting the repo lock error when running a prune. I have had to seperate my scheduled backup tasks into two seperate jobs to overcome the lock issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants