More > JRiver Media Center 33 for Windows

Backup from command line?

<< < (5/6) > >>

zybex:
This .bat restores the most recent ZIP backup in a given folder:


--- Code: ---@echo off
if "%1"=="" echo Usage: MCRestoreLatest c:\Backup\Folder\Path & goto :EOF
set folder=%1
set mask=*.zip

FOR /F "eol=| delims=" %%f IN ('DIR "%folder%\%mask%" /A-D /B /O-D /TW 2^>nul') DO SET "newest=%%f" & GOTO FOUND
echo No %mask% file found in %folder%
GOTO :EOF

:FOUND
echo.
echo Newest file is: "%newest%"
echo.
echo Restoring MC Database in 5 seconds, press CTRL+C to cancel
timeout 5

echo.
mc33.exe /RestoreLibraryAndSettings "%folder%\%newest%"
--- End code ---

MarkCoutinho:

--- Quote from: zybex on October 01, 2024, 12:54:52 pm ---You just need a script to automatically determine the most recent filename.

Just curious, why would you automate a DB restore?

--- End quote ---
I use it only to automate the restore process as much as I can by hitting just one (combination of) key(s).

MarkCoutinho:

--- Quote from: MarkCoutinho on October 02, 2024, 10:10:05 am ---I use it only to automate the restore process as much as I can by hitting just one (combination of) key(s).

--- End quote ---
Super, thanks! I'm not home right now, but I will give your code a go.

MarkCoutinho:
As Zybex has published the restore batch he made, I feel free to show the backup batch I've made.
This batch backs up the library and then renames it to the way MC by default names its back up files. You just have to adjust your own paths.


@echo off
MC33.exe /BackupLibrary "c:\Users\Mark\Google Drive\MediaCenter backups\MC Library Backup.zip"

:: set pause to wait for the backup process to finish
timeout 10

setlocal

:: Retrieve date and time in the correct format (yyyy-MM-dd HH-mm)
for /f "tokens=2-4 delims=/- " %%a in ('date /t') do (
    set year=%%c
    set month=%%b
    set day=%%a
)

for /f "tokens=1-2 delims=:." %%a in ('time /t') do (
    set hour=%%a
    set minute=%%b
)

:: Convert time to 24-hour format as needed
if %hour% lss 10 set hour=0%hour%

:: Set old file name and path
set "source=c:\Users\Mark\Google Drive\MediaCenter backups\MC Library Backup.zip"
set "path=c:\Users\Mark\Google Drive\MediaCenter backups\"
::set "filename=MC Library Backup %year%-%month%-%day% %hour%-%minute%.zip"
set "filename=MC Library Backup (Main Library - %year%-%month%-%day% %hour%-%minute%).zip"
 
:: Rename file
ren "%source%" "%filename%"

echo File renamed to: %path%%filename%

endlocal

MarkCoutinho:

--- Quote from: Matt on September 27, 2024, 06:34:33 pm ---I think /RestoreLibrary should already work.  There's also /RestoreLibraryAndSettings and /RestoreSettings.

--- End quote ---
I've done some extensive testing, but /RestoreLibraryAndSettings and /RestoreSettings both don't restore the settings, so that needs some adjustment.
If I restore the library 'by hand' (with the same zip file) the settings are being restored as expected. But that's not the case with the command

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version