It seems that for some reason when I run the same command in a different file, I get and error message of "unknown command “./pw” for “restic”
I also have the error of “unknown flag --dry-run” and “–repack-uncompressed” also tried with “–repack-uncompressed=true” when running prune ← I read up on this a bit and there seemed to be a consensus that the “–dry-run” flag wasn’t implemented in the 0.11.0 release but instead is functional in the forget command as of version 0.13.0.
🍒 ~/Scripts/Backups🔒
🐡ish Terminal ➜ restic version
restic 0.14.0 compiled with go1.19 on linux/amd64
🍒 ~/Scripts/Backups🔒
🐡ish Terminal ➜ la list-snapshots.sh prune-s3-repo.sh
.rwxr-xr-x root root 105 B Fri Nov 18 13:35:20 2022 list-snapshots.sh
.rwxr-xr-x root root 737 B Fri Nov 18 14:04:35 2022 prune-s3-repo.sh
Without knowing more about the script, my guess would be that there’s something wrong related to quoting the command parameters. But without the script that’s pure guesswork.
Make sure to put those options after prune. --repack-uncompressed was added in restic 0.14.0.
Without knowing more about the script, my guess would be that there’s something wrong related to quoting the command parameters. But without the script that’s pure guesswork.
If you mean what’s inside the “./pw” file. It’s just a plaintext of my password. I have all my scripts setup as such and so far I’ve been able to backup and also list-snapshost with that syntax.
Make sure to put those options after prune . --repack-uncompressed was added in restic 0.14.0.
Also as you can see from the above, I tested the script with different flags and syntax, each on it’s own run, while commenting out the command lines I wasn’t testing at that given execution.
EDIT: It seems that for whatever reason this issue is specific to the script file i’ve created because I recreated the script with list-snapshots.sh by:
1) cp list-snapshots.sh test-prune.sh
2) vim into it and delete unnecessary commands
3) add line "restic -r $RESTIC_REPOSITORY $PASS prune --dry-run --repack-uncompressed --repack-smaller"
When I run the script I get the output:
🍒 ~/Scripts/Backups🔒
🐡ish Terminal ➜ ./test-prune.sh
repository 7e639bb7 opened (repository version 2) successfully, password is correct
loading indexes...
loading all snapshots...
finding data that is still in use for 4 snapshots
[0:04] 100.00% 4 / 4 snapshots
searching used packs...
collecting packs for deletion and repacking
[0:01] 100.00% 10862 / 10862 packs processed
to repack: 447997 blobs / 167.655 GiB
this removes: 10158 blobs / 1.665 GiB
to delete: 11772 blobs / 9.770 GiB
total prune: 21930 blobs / 11.435 GiB
remaining: 506382 blobs / 214.972 GiB
unused size after prune: 2.248 GiB (1.05% of remaining size)
🍒 ~/Scripts/Backups🔒
🐡ish Terminal ✗ la prune-s3-repo.sh test-prune.sh
.rwxr-xr-x root root 146 B Sun Nov 20 01:22:44 2022 prune-s3-repo.sh
.rwxr-xr-x root root 148 B Sun Nov 20 01:20:30 2022 test-prune.sh
In your not-working script the “./pw” is taken as the repository (the -p is missing).
But as you pointed out, this is not a restic issue but a script issue you are dealing with. Maybe try one of the various wrapper scripts available for restic?
(BTW: This is a good example why a config file support does help to improve the application)
Oh nice catch. Thanks!
I did correct that error and it does resort back to the original error of:
🍒 ~/Scripts/Backups🔒 took 11s
🐡ish Terminal ➜ ./prune-s3-repo.sh
unknown command "./pw" for "restic"
I also edit my params file and add: export RESTIC_PASSWORD='<password>'
but that seems to out the same error but with a slight difference:
🍒 ~/Scripts/Backups🔒 took 11s
🐡ish Terminal ➜ ./prune-s3-repo.sh
unknown command "<password>" for "restic"
Also interesting, I didn’t realize restic had wrapper scripts for a streamlined process. I do understand your reasoning but honestly I would like to create the scripts myself just for the experience. Also I like it!!
And there’s another error:
🍒 ~/Scripts/Backups🔒
🐡ish Terminal ➜ ./prune-s3.sh
Resolving password failed: Fatal: <password> does not exist
Could this be because I used ‘single quotes’ to encapsulate the password?
What can the possible reasons be for these sort of errors?
I’ve missed the scripts inbetween all the other output and all these emojis .
There’s another typo here. It should be repository, not reSpository.
When using variables in a command line please add quotes unless you know that these are not necessary. And I’d recommend to add a set -eu line at the top of the script, the e will cause the script to abort if there’s a non-zero exit code (which is currently silently swallowed by your wrapper script). And the u will cause bash to err out if a variable is undefined. For debugging set -x is also quite helpful.