This is the script I run on Windows when I sense some imminent risk before bulk library operations:
PHP Code:
@echo off
Title Calibre Metadata Backup
echo [93mRunning Calibre Metadata Backup...
@echo off
set dt="%date:~-4,4%-%date:~-7,2%-%date:~-10,2%,%time:~0,2%_%time:~3,2%_%time:~6,2%"
set file=c:\mylib\metadata.db
set target=%UserProfile%\Documents\metadata-bck.db
copy /Y %file% %target%
cd %UserProfile%\Documents
"c:\Program Files\7-zip\7z.exe" a -mx=1 metadata-%dt%.7z metadata-bck.db
del metadata-bck.db
echo [44mMetadata Backup done. File is located in %target%.[0m
pause
Notes:
- must have 7-zip installed and install path set accordingly. In my Calibre Config backup script, I use Windows built-in tar command, but for some reason I've chosen 7-zip to do metadata.db backups.
- must change the library path at line "set file=". I suspect that if the library path contains spaces, it should be quoted, but haven't tested.
- Compression levels may be set to the following:
-mx0 = Don't compress at all - just copy the contents to archive.
-mx1 = Consumes least time, but compression is low.
-mx3 = Better than -mx1.
-mx5 = This is default (compression is normal).
-mx7 = Maximum compression.
-mx9 = Ultra compression.
- I've set the backup path to Documents because that's a folder I use all the time so i can delete unneeded backups as soon as I spot them.