Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Il nuovo SessionStoreBackup è pensato per Firefox 57 e superiori, e lavora ora sui nuovi jsonlz4 compressi. Leggi l'articolo dedicato su https://wp.me/pdQ5q-8PN
REM =====================================================================================================================
REM NOME DEL PROFILO (DA CONFIGURARE)
REM Se non sai cosa fare, leggi https://wp.me/pdQ5q-8PN
REM =====================================================================================================================
set NOMEPROFILO=TUOPROFILO.default
REM =====================================================================================================================
REM NON TOCCARE NIENTE DA QUI IN POI!
REM =====================================================================================================================
@echo off
setlocal enabledelayedexpansion
cls
echo SessionStoreBackup 0.7 per Firefox 57+
echo ult.mod. 22/8/17, GSolone (gf.solone@mozillaitalia.org)
echo info: http://wp.me/pdQ5q-1BY
echo ---------------------------------------------------------------------------------
:Preparazione
echo;
echo Lettura directory e file di salvataggio sessione ...
echo;
set sessionFileDir=%appdata%\Mozilla\Firefox\Profiles\%NOMEPROFILO%\sessionstore-backups\
set sessionBackupDir=%appdata%\Mozilla\Firefox\Profiles\%NOMEPROFILO%\
set sessionRecoveryFileName=recovery
set sessionPreviousFileName=previous
set sessionFileSuffix=.jsonlz4
if not exist "%sessionFileDir%%sessionRecoveryFileName%%sessionFileSuffix%" (echo File di recovery sessione non trovato, termino il programma. && GOTO :End)
if not exist "%sessionBackupDir%SessionStoreBackup" mkdir %sessionBackupDir%SessionStoreBackup
:MD5
REM File Recovery sorgente
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile "%sessionFileDir%%sessionRecoveryFileName%%sessionFileSuffix%" MD5') do (
if !count! equ 1 set "md5RecoverySource=%%a"
set/a count+=1
)
set "md5RecoverySource=%md5RecoverySource: =%
echo Hash Source Recovery %md5RecoverySource%
REM File Previous sorgente
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile "%sessionFileDir%%sessionPreviousFileName%%sessionFileSuffix%" MD5') do (
if !count! equ 1 set "md5PreviousSource=%%a"
set/a count+=1
)
set "md5PreviousSource=%md5PreviousSource: =%
echo Hash Source Previous %md5PreviousSource%
REM File Recovery destinazione
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile "%sessionBackupDir%SessionStoreBackup\%sessionRecoveryFileName%%sessionFileSuffix%" MD5') do (
if !count! equ 1 set "md5RecoveryDest=%%a"
set/a count+=1
)
set "md5RecoveryDest=%md5RecoveryDest: =%
echo Hash Destination Recovery %md5RecoveryDest%
REM File Previous destinazione
set /a count=1
for /f "skip=1 delims=:" %%a in ('CertUtil -hashfile "%sessionBackupDir%SessionStoreBackup\%sessionPreviousFileName%%sessionFileSuffix%" MD5') do (
if !count! equ 1 set "md5PreviousDest=%%a"
set/a count+=1
)
set "md5PreviousDest=%md5PreviousDest: =%
echo Hash Destination Previous %md5PreviousDest%
echo;
if %md5RecoverySource% == %md5RecoveryDest% (echo File di sessione recovery esistente, backup non necessario, avanzo.)
if %md5PreviousSource% == %md5PreviousDest% (echo File di sessione previous esistente, backup non necessario, termino il programma. && GOTO :End)
:Start
IF NOT EXIST "%sessionBackupDir%%sessionRecoveryFileName%%sessionFileSuffix%" (
echo Creo i file di backup ...
echo;
copy "%sessionFileDir%%sessionRecoveryFileName%%sessionFileSuffix%" "%sessionBackupDir%%sessionRecoveryFileName%%sessionFileSuffix%"
copy "%sessionFileDir%%sessionPreviousFileName%%sessionFileSuffix%" "%sessionBackupDir%%sessionPreviousFileName%%sessionFileSuffix%"
echo;
echo Sposto i file nella cartella di backup ...
echo;
move "%sessionBackupDir%%sessionRecoveryFileName%%sessionFileSuffix%" "%sessionBackupDir%SessionStoreBackup\"
move "%sessionBackupDir%%sessionPreviousFileName%%sessionFileSuffix%" "%sessionBackupDir%SessionStoreBackup\"
echo;
echo Backup completato in
echo "%sessionBackupDir%SessionStoreBackup\%sessionRecoveryFileName%%sessionFileSuffix%"
echo "%sessionBackupDir%SessionStoreBackup\%sessionPreviousFileName%%sessionFileSuffix%"
echo;
)
:End
endlocal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment