Reduced the output

This commit is contained in:
2026-03-29 13:03:47 +02:00
parent e1d9f968a9
commit c7d46d7186
2 changed files with 16 additions and 10 deletions
+2 -2
View File
@@ -53,11 +53,11 @@ else
if [[ "$HC_PING_KEY" ]] ; then if [[ "$HC_PING_KEY" ]] ; then
echo -n " runitor -slug ${HOSTNAME}-restic-forget --" >> /tmp/crontab echo -n " runitor -slug ${HOSTNAME}-restic-forget --" >> /tmp/crontab
fi fi
echo -n " restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 2 --prune >> /var/log/cron.log &&" >> /tmp/crontab echo -n " restic forget -q --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --keep-yearly 2 --prune >> /var/log/cron.log &&" >> /tmp/crontab
if [[ "$HC_PING_KEY" ]] ; then if [[ "$HC_PING_KEY" ]] ; then
echo -n " runitor -slug ${HOSTNAME}-restic-check --" >> /tmp/crontab echo -n " runitor -slug ${HOSTNAME}-restic-check --" >> /tmp/crontab
fi fi
echo -n " restic check >> /var/log/cron.log" >> /tmp/crontab echo -n " restic check -q >> /var/log/cron.log" >> /tmp/crontab
if [[ "$POST_MAINTENANCE_COMMAND" ]] ; then if [[ "$POST_MAINTENANCE_COMMAND" ]] ; then
echo -n " && $POST_MAINTENANCE_COMMAND" >> /tmp/crontab echo -n " && $POST_MAINTENANCE_COMMAND" >> /tmp/crontab
fi fi
+14 -8
View File
@@ -7,7 +7,7 @@ function backup_dir {
echo "[ERROR] Cannot backup the root directory. Have you correctly configured the volumes to backup for this container ?" echo "[ERROR] Cannot backup the root directory. Have you correctly configured the volumes to backup for this container ?"
return -1 return -1
elif [ -d "/root_fs$1" ]; then elif [ -d "/root_fs$1" ]; then
restic backup $RESTIC_BACKUP_FLAGS /root_fs$1 restic backup -q $RESTIC_BACKUP_FLAGS /root_fs$1
return $? return $?
else else
echo "[ERROR] Directory $1 not found. Have you mounted the root fs from your host with the following option : '-v /:/root_fs:ro' ?" echo "[ERROR] Directory $1 not found. Have you mounted the root fs from your host with the following option : '-v /:/root_fs:ro' ?"
@@ -20,7 +20,7 @@ function backup_local_dir {
echo "[ERROR] Cannot backup the root directory. Have you correctly configured the volumes to backup for this container ?" echo "[ERROR] Cannot backup the root directory. Have you correctly configured the volumes to backup for this container ?"
return -1 return -1
elif [ -d "$1" ]; then elif [ -d "$1" ]; then
restic backup $RESTIC_BACKUP_FLAGS $1 restic backup -q $RESTIC_BACKUP_FLAGS $1
return $? return $?
else else
echo "[ERROR] Directory $1 not found." echo "[ERROR] Directory $1 not found."
@@ -30,17 +30,19 @@ function backup_local_dir {
# Backup one file # Backup one file
function backup_file { function backup_file {
cat $1 | restic backup $RESTIC_BACKUP_FLAGS --stdin --stdin-filename $2 cat $1 | restic backup -q $RESTIC_BACKUP_FLAGS --stdin --stdin-filename $2
return $? return $?
} }
# Firt, check the repository is unlocked and try to unlock it # Firt, check the repository is unlocked and try to unlock it
if [ "$(restic --no-lock list locks -q)" != "" ]; then if [ "$(restic --no-lock list locks -q)" != "" ]; then
echo "[INFO] Repository locked, trying to unlock" echo -n "[INFO] Repository locked, trying to unlock ... "
restic unlock restic unlock
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "[ERROR] Could not unlock repository" echo "[ERROR] Could not unlock repository"
return -1 return -1
else
echo "done."
fi fi
fi fi
@@ -67,11 +69,12 @@ for container_id in $(docker ps -aq) ; do
backup_dirs=$(echo $container_json | jq -r '.[].Config.Labels."napnap75.backup.dirs"') backup_dirs=$(echo $container_json | jq -r '.[].Config.Labels."napnap75.backup.dirs"')
if [ "$backup_dirs" != "null" ] ; then if [ "$backup_dirs" != "null" ] ; then
for dir_name in $backup_dirs ; do for dir_name in $backup_dirs ; do
echo "[INFO] Backing up dir" $dir_name "for container" $container_name echo -n "[INFO] Backing up dir" $dir_name "for container" $container_name " ... "
backup_dir $dir_name backup_dir $dir_name
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
((++count_failure)) ((++count_failure))
else else
echo "done."
((++count_success)) ((++count_success))
fi fi
done done
@@ -82,11 +85,12 @@ for container_id in $(docker ps -aq) ; do
if [ "$backup_dirs" != "null" ] ; then if [ "$backup_dirs" != "null" ] ; then
if [[ "$(echo $container_json | jq -r '.[].Config.Image')" == "napnap75/restic-auto"* ]] ; then if [[ "$(echo $container_json | jq -r '.[].Config.Image')" == "napnap75/restic-auto"* ]] ; then
for dir_name in $backup_dirs ; do for dir_name in $backup_dirs ; do
echo "[INFO] Backing up local dir" $dir_name "for container" $container_name echo -n "[INFO] Backing up local dir" $dir_name "for container" $container_name " ... "
backup_local_dir $dir_name backup_local_dir $dir_name
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
((++count_failure)) ((++count_failure))
else else
echo "done."
((++count_success)) ((++count_success))
fi fi
done done
@@ -100,11 +104,12 @@ for container_id in $(docker ps -aq) ; do
if [ "$backup_volumes" != "null" ] ; then if [ "$backup_volumes" != "null" ] ; then
for volume_name in $backup_volumes ; do for volume_name in $backup_volumes ; do
volume_mount=$(echo $container_json | jq -r ".[].Mounts[] | select(.Name==\"$volume_name\") | .Source") volume_mount=$(echo $container_json | jq -r ".[].Mounts[] | select(.Name==\"$volume_name\") | .Source")
echo "[INFO] Backing up volume" $volume_name "with mount" $volume_mount "for container" $container_name echo -n "[INFO] Backing up volume" $volume_name "with mount" $volume_mount "for container" $container_name " ... "
backup_dir $volume_mount backup_dir $volume_mount
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
((++count_failure)) ((++count_failure))
else else
echo "done."
((++count_success)) ((++count_success))
fi fi
done done
@@ -114,7 +119,7 @@ for container_id in $(docker ps -aq) ; do
backup_databases=$(echo $container_json | jq -r '.[].Config.Labels."napnap75.backup.databases"') backup_databases=$(echo $container_json | jq -r '.[].Config.Labels."napnap75.backup.databases"')
if [ "$backup_databases" != "null" ] ; then if [ "$backup_databases" != "null" ] ; then
for database_name in $backup_databases ; do for database_name in $backup_databases ; do
echo "[INFO] Backing up database" $database_name "for container" $container_name echo -n "[INFO] Backing up database" $database_name "for container" $container_name " ... "
docker exec $container_id bash -c "/usr/bin/mariadb-dump --databases $database_name | gzip -c > /tmp/database_backup.sql.gz" docker exec $container_id bash -c "/usr/bin/mariadb-dump --databases $database_name | gzip -c > /tmp/database_backup.sql.gz"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "[ERROR] Unable to backup database $database_name from container $container_name" echo "[ERROR] Unable to backup database $database_name from container $container_name"
@@ -125,6 +130,7 @@ for container_id in $(docker ps -aq) ; do
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
((++count_failure)) ((++count_failure))
else else
echo "done."
((++count_success)) ((++count_success))
fi fi
fi fi