updated cron, moved clean to cron. added days to keep

This commit is contained in:
2020-11-18 11:30:20 -05:00
parent a772c52c9d
commit 009bf6193a
2 changed files with 7 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "duplicacy",
"version": "20201117.2q",
"version": "20201118.1",
"slug": "duplicacy",
"description": "Duplicacy backup",
"arch": ["armhf", "armv7"],
@@ -16,6 +16,7 @@
"server": "server.example.com",
"path": "/opt/some/folder/on/on/server",
"crontab_run": "0 2 * * 5",
"days_to_keep": "14",
"filters": [
"i:addons/.*",
"i:backup/.*",
@@ -32,6 +33,7 @@
"server": "str",
"path": "str",
"crontab_run": "str",
"days_to_keep": "int",
"filters": ["match(^i:|e:)"]
}
}

View File

@@ -13,6 +13,7 @@ BACKUP_SERVER=$(jq --raw-output ".server" $CONFIG_PATH)
BACKUP_SERVER_PATH=$(jq --raw-output ".path" $CONFIG_PATH)
FILTERS=$(jq --raw-output ".filters" $CONFIG_PATH)
CRONTAB_RUN=$(jq --raw-output ".crontab_run" $CONFIG_PATH)
DAYS_TO_KEEP=$(jq --raw-output ".days_to_keep" $CONFIG_PATH)
# edit the /.duplicacy/preferences file
sed --in-place 's/<BACKUP_ID>/'${BACKUP_ID}'/' /.duplicacy/preferences
@@ -25,10 +26,7 @@ sed --in-place 's~<BACKUP_SERVER_PATH>~'${BACKUP_SERVER_PATH}'~' /.duplicacy/pre
# create the filters file
echo ${FILTERS} | jq -r '.[]' >> /.duplicacy/filters
# backup all the data using cron
echo "${CRONTAB_RUN} /duplicacy -verbose -log backup -stats" >> /etc/crontabs/root
# backup all the data using cron and then remove the
echo "${CRONTAB_RUN} /duplicacy -verbose -log backup -stats; find /backup/* -type f -name '*.tar' -mtime +${DAYS_TO_KEEP} -exec rm {} \;" >> /etc/crontabs/root
# run the cron daemon in the forground
/usr/sbin/crond -f
# remove old backups
find /backup/* -type f -name '*.tar' -mtime +14 -exec rm {} \;
/usr/sbin/crond -f -l 0