Commit 8c8c8193 authored by OskarStenberg's avatar OskarStenberg
Browse files

Added csv backup, and support for newlines in file names

parent 9257d5e1
......@@ -4,7 +4,7 @@ backupDirectory="$snipeitDirectory/storage/app/backups"
#/ Usage: [-dbmof]
#/ Usage: [-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-)"
#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"
rm -Rf "$backupDirectory/$backupFile"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment