diff --git a/backup.sh b/backup.sh index 28fd154124367278863f18622ffaaf59af55ffcc..a3849b754202df22dc633816ca5fae691b5586ea 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"