From 8e3068680a6bf071435654a7b4399d23a27e56f2 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Mon, 15 Nov 2021 19:51:31 +0200
Subject: [PATCH] Don't complain on missing files.

Removing existing backups is needed if they exist. But the output is
littered with rm complaining about non-existing files. Instead, check if
the file exists, then remove it.
---
 backup/backup | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/backup/backup b/backup/backup
index fe42de0..a3ea414 100755
--- a/backup/backup
+++ b/backup/backup
@@ -36,7 +36,7 @@ NR>2 {
         image_url = registry "/" $1 ":" $(i)
         image_file = dest "/" $1 "/" $(i) ".tar"
         printf "Saving %s to %s.\n", image_url, image_file
-        system("rm " image_file)
+        system("[ -f " image_file " ] || rm " image_file)
         if (system("skopeo copy docker://" image_url " docker-archive://" image_file) == 0)
             printf "Backup of %s was successful.\n", image_url
         else {
-- 
GitLab