View Single Post
Old 01-27-2025, 05:49 PM   #7
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,614
Karma: 7891011
Join Date: Sep 2020
Device: none
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 
/%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 doneFile 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.
Attached Files
File Type: bat metadata.db_backup.bat (523 Bytes, 72 views)

Last edited by Comfy.n; 01-27-2025 at 05:52 PM.
Comfy.n is offline   Reply With Quote