From 8c8c81935891a3fcab551669f4a86d2d4c59404c Mon Sep 17 00:00:00 2001 From: Oskar Stenberg <01ste02@gmail.com> Date: Wed, 14 Jul 2021 13:26:34 +0200 Subject: [PATCH] Added csv backup, and support for newlines in file names --- backup.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backup.sh b/backup.sh index 28fd15412..a3849b754 100755 --- a/backup.sh +++ b/backup.sh @@ -4,7 +4,7 @@ backupDirectory="$snipeitDirectory/storage/app/backups" dbDumpFile="$snipeitDirectory/vendor/spatie/db-dumper/src/Databases/MySql.php" destinationDir="/export/home/snipeit/backups" -#/ Usage: backup.sh [-dbmof] +#/ Usage: backup.sh [-dbmofh] #/ #/ Create an incremental backup of a snipeit-instance #/ @@ -117,7 +117,7 @@ mkdir new unzip -qq "$backupDirectory/$backupFile" -d "./$extractDir" > /dev/null 2>&1 cd $extractDir echo "Copied:" -find . -path ".$snipeitDirectory/public/uploads/barcodes" -prune -o -print| egrep '(*\.png|*\.jpg|*\.webp|*\.gif|*\.svg|\.env)$' | cpio -pdmu ../new/ +find . -path ".$snipeitDirectory/public/uploads/barcodes" -prune -o -print0| egrep -zZ '(*\.png|*\.jpg|*\.webp|*\.gif|*\.svg|\.env|*csv)$' | cpio -0pdmu ../new/ cd ../ cp -r $extractDir/db-dumps new/ @@ -152,7 +152,7 @@ while IFS= read -r file; do cp -u --parents "$file" "$destinationDir/$lastBackup/" echo "Copied $file $destinationDir/$lastBackup/$(echo $file | cut -c 3-)" else - #Om filen redan finns, kolla om den finns i en nyare version på disken. Om den är nyare, kolla om den redan patchats. + #If the file already exists, check if there is a newer version in the local backup. If it is newer than the original file, check if it has already been patched. if [ "$destinationDir/$lastBackup/$(echo $file | cut -c 3-)" -ot "$file" ]; then lastFilePatch=$(ls -lt "$destinationDir/$lastBackup/patches/files" | head -2 | tail -1 | awk '{print $9}') if [ "$destinationDir/$lastBackup/patches/files/$lastFilePatch/$(echo $file | cut -c 3-)" -ot "$file" ]; then @@ -196,3 +196,5 @@ else echo "Nothing to patch" fi fi + +rm -Rf "$backupDirectory/$backupFile" -- GitLab