Comments (13)
As I wrote, I would have to specifiy 4 different files for the 4 periods in the original example crontab. However, one can also use @file with additional parameters. So, I modified the crontab entry to this:
PATH=/usr/bin:/bin:/usr/local/bin/
MAILTO="[email protected]"
SNAP_CREDENTIALS=/etc/cv4pve-autosnap/credentials.conf
# "all" for all VMs, exceptions with "-123" possible, or just the following VMs: "123,124"
SNAP_VMID="all,-105"
SNAP_KEEP_HOURLY=23
SNAP_KEEP_DAILY=6
SNAP_KEEP_WEEKLY=4
SNAP_KEEP_MONTHLY=3
# hourly
1 1-23 * * * root cv4pve-autosnap @"$SNAP_CREDENTIALS" --vmid="$SNAP_VMID" snap --only-running --label="hourly" --keep="$SNAP_KEEP_HOURLY" > /dev/null
# weekly -> So; daily -> Mo-Sa
1 0 2-31 * * root [ "$(date +\%u)" = "7" ] && cv4pve-autosnap @"$SNAP_CREDENTIALS" --vmid="$SNAP_VMID" snap --only-running --label="weekly" --keep="$SNAP_KEEP_WEEKLY" > /dev/null || cv4pve-autosnap @"$SNAP_CREDENTIALS" --vmid="$SNAP_VMID" snap --only-running --label="daily" --keep="$SNAP_KEEP_DAILY" > /dev/null
# monthly
1 0 1 * * root cv4pve-autosnap @"$SNAP_CREDENTIALS" --vmid="$SNAP_VMID" snap --only-running --label="monthly" --keep="$SNAP_KEEP_MONTHLY" > /dev/null
With /etc/cv4pve-autosnap/credentials containing this:
--host=127.0.0.1 --api-token=--host=127.0.0.1 --api-token=snapshot@pam!snapshot=42cfa924-0c23-4b9f-9eba-db62c3984b33
or this:
--host=127.0.0.1 --username=snapshot@pam --password=snappass
from cv4pve-autosnap.
Hi,
This is a format user from Proxmox
from cv4pve-autosnap.
I know that, but the way it is given to the program makes it impossible to use. If the parameter format for cv4pve-autosnap was not like "--xxx=yyy", but "-x yyy", there was no problem if an API token like USER@REALM!TOKENID=UUID was provided.
The problem is the second '=', since after crontab expansion is used, all is left is "--api-token=USER@REALM!TOKENID=UUID" without any possibility of quoting it. That remaining string is cut off at the second '='.
from cv4pve-autosnap.
Hi,
You can use wothout =,
--api-token USER@REALM!TOKENID=UUID
from cv4pve-autosnap.
It tried, but within a crontab, it does not work. It is capped at the '='.
from cv4pve-autosnap.
In shell work?
from cv4pve-autosnap.
If you wanth can specify esternal file for parameters.
from cv4pve-autosnap.
https://github.com/Corsinvest/cv4pve-autosnap#execution-with-file-parameter
from cv4pve-autosnap.
Yes, it works in a shell because there, I can quote, which is not possible in a crontab entry. Here is the full example for /etc/cron.d/whatever:
PATH=/usr/bin:/bin:/usr/local/bin/
MAILTO="[email protected]"
SNAP_HOST="127.0.0.1"
SNAP_USER="snapshot@pam"
SNAP_PASS="snappass"
SNAP_APITOKEN="snapshot@pam!snapshot=42cfa924-0c23-4b9f-9eba-db62c3984b33"
# "all" for all VMs, exceptions with "-105"
SNAP_VMID="all,-105'
SNAP_KEEP_HOURLY=23
SNAP_KEEP_DAILY=6
SNAP_KEEP_WEEKLY=4
SNAP_KEEP_MONTHLY=3
# hourly
#1 1-23 * * * root cv4pve-autosnap --host="$SNAP_HOST" --username="$SNAP_USER" --password="$SNAP_PASS" --vmid="$SNAP_VMID" snap --only-running --label="hourly" --keep="$SNAP_KEEP_HOURLY" > /dev/null
* * * * * root cv4pve-autosnap --host="$SNAP_HOST" --api-token="$SNAP_APITOKEN" --vmid="$SNAP_VMID" snap --only-running --label="minute" --keep="$SNAP_KEEP_HOURLY"
As you can see, I commented out and modified the username/passwd version in order to send mail of the output and start once every minute. You have to modify MAILTO to get the results. I have tried every imaginable way of quoting and escaping - including using a space after --api-token, but this never works. And obviously, the user/pass and api-tokens are not real.
The example is from here: https://techlr.de/proxmox-automatische-snapshots-einrichten/ , thus there are a few lines missing. They all use the same parameters, so it is not really feasible to insert the API key literally everywhere.
Specifying in a file is difficult if you want to have it centrally in a crontab file, especially if you have multiple invocations. I would need 4 additional parameter files, although it would be a valid workaround.
from cv4pve-autosnap.
Try with ' symbol to esecute command
'cv4pve-autosnap ...'
from cv4pve-autosnap.
No, that is interpreted as one whole string when given to /bin/sh, also the expansions are not done within single quotes:
/bin/sh: 1: cv4pve-autosnap --host="$SNAP_HOST" --api-token="$SNAP_APITOKEN" --vmid="$SNAP_VMID" snap --only-running --label="minute" --keep="$SNAP_KEEP_HOURLY" : not found
from cv4pve-autosnap.
It is a fine line to keep expanding parameters and having the result kept together despite containing special characters.
Even the '!' is a problem there, because it has special meaning in a shell. That is why you need single quotes around the API token in an interactive shell.
from cv4pve-autosnap.
External file with all comman line is a solution
from cv4pve-autosnap.
Related Issues (20)
- Save snap to another storage HOT 2
- Same error trying to snap on proxmox 6.2 HOT 9
- Proxmox 7.2-11 issues HOT 3
- [FEATURE] Add an option to snapshot only running VMs/CTs HOT 4
- Can this be made possible to run locally on the proxmox server shell? HOT 3
- Feature: Snap from tags HOT 7
- Is it safety to use cv4pve-autosnap in conjunction with Storage Replication (pvecm)? HOT 7
- Obsolete defaults-extra-file HOT 1
- Object reference not set to an instance of an object. HOT 2
- Cannot exclude vm disks HOT 3
- Include an example of how to use a snapshot to restore a VM/CT ? HOT 1
- Can't snapshot a VM without disk HOT 4
- No usable version of libssl was found HOT 6
- Documentation unclear about exclusions in vmid parameter and missing other parameters HOT 15
- Feature: Option to disable Memory on snapshot HOT 1
- Incomplete error handling (or lack of filtering) for "non-snapshottable" machines HOT 1
- Destination storage HOT 2
- is promox 8 supported? HOT 1
- Capture snapshot with RAM HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cv4pve-autosnap.