69 lines
3.7 KiB
Batchfile
Executable File
69 lines
3.7 KiB
Batchfile
Executable File
@echo off
|
|
|
|
REM Ce script permet de sauvegarder les profiles
|
|
REM de Thunderbird et Firefox
|
|
REM Il conserve les 10 dernières version de chaque
|
|
|
|
REM Si la fonction n'est pas activée, on s'arrête là
|
|
IF "%MOZBACKUP%" NEQ "yes" GOTO :EOF
|
|
|
|
REM L'archivage des profile va utiliser 7-Zip
|
|
REM On s'arrête si cet outil n'est pas disponible
|
|
SET ZIP="%PROGRAMFILES%\7-Zip\7z.exe"
|
|
IF NOT EXIST %ZIP% GOTO :EOF
|
|
|
|
REM Les sauvegardes seront stockées dans un répertoire caché
|
|
REM du dossier personnel. Un sous répertoire est créé pour chaque
|
|
REM machine de l'utilisateur
|
|
SET DEST="\\%IPASSERELLE_IP%\%USERNAME%\.backup\%COMPUTERNAME%"
|
|
|
|
IF NOT EXIST "%DEST%" mkdir "%DEST%"
|
|
IF NOT EXIST "%DEST%" GOTO :EOF
|
|
|
|
REM Recherche du répertoire de profile de Thunderbird
|
|
for /f %%a in ('dir /b "%APPDATA%\Thunderbird\Profiles\*.default"') do SET TBPROFILE=%APPDATA%\Thunderbird\Profiles\%%a
|
|
|
|
REM Si le répertoire de profile n'existe pas, on s'arrête
|
|
IF NOT EXIST "%TBPROFILE%" :EOF
|
|
|
|
REM Rotation des anciennes sauvegardes
|
|
REM Pas très élégant, mais on fait ce qu'on peut
|
|
REM souvenez-vous qu'on est qu'en batch ;-)
|
|
IF EXIST "%DEST%\thunderbird10.7z" DEL /Q /F "%DEST%\thunderbird10.7z"
|
|
IF EXIST "%DEST%\thunderbird9.7z" REN "%DEST%\thunderbird9.7z" thunderbird10.7z
|
|
IF EXIST "%DEST%\thunderbird8.7z" REN "%DEST%\thunderbird8.7z" thunderbird9.7z
|
|
IF EXIST "%DEST%\thunderbird7.7z" REN "%DEST%\thunderbird7.7z" thunderbird8.7z
|
|
IF EXIST "%DEST%\thunderbird6.7z" REN "%DEST%\thunderbird6.7z" thunderbird7.7z
|
|
IF EXIST "%DEST%\thunderbird5.7z" REN "%DEST%\thunderbird5.7z" thunderbird6.7z
|
|
IF EXIST "%DEST%\thunderbird4.7z" REN "%DEST%\thunderbird4.7z" thunderbird5.7z
|
|
IF EXIST "%DEST%\thunderbird3.7z" REN "%DEST%\thunderbird3.7z" thunderbird4.7z
|
|
IF EXIST "%DEST%\thunderbird2.7z" REN "%DEST%\thunderbird2.7z" thunderbird3.7z
|
|
IF EXIST "%DEST%\thunderbird1.7z" REN "%DEST%\thunderbird1.7z" thunderbird2.7z
|
|
|
|
REM On compresse tout le profile, sauf le répertoire ImapMail (qui peut être énorme)
|
|
REM le fichier global-message-db.sqlite (peut faire plusieurs Go) et quelques autres fichiers non essentiels
|
|
REM On utilise le plus faible taux de compression pour éviter de prendre trop de temps
|
|
REM vu que ce script sera lancé à l'ouverture de session
|
|
%ZIP% a -t7z -mx1 "%DEST%\thunderbird1.7z" "%TBPROFILE%\*" -x!key3 -xr!"ImapMail\" -x!global-messages-db.sqlite -x!Cache -x!SOGoImageCache -x!startupCache -x!places.sqlite -x!urlclassifier3.sqlite -x!cookies.sqlite
|
|
REM Maintenant, on rajoute à l'archive les fichiers .dat contenus dans le répertoire ImapMail
|
|
REM Ces fichiers contiennent en particulier les filtres des messages
|
|
REM pas trouvé comment faire ça en une seule passe
|
|
%ZIP% a -t7z -mx1 -r "%DEST%\thunderbird1.7z" "%TBPROFILE%\*.dat"
|
|
|
|
REM Même chose pour Firefox maintenant
|
|
for /f %%a in ('dir /b "%APPDATA%\Mozilla\Firefox\Profiles\*.default"') do SET FFPROFILE=%APPDATA%\Mozilla\Firefox\Profiles\%%a
|
|
IF NOT EXIST "%FFPROFILE%" GOTO :EOF
|
|
|
|
IF EXIST "%DEST%\firefox10.7z" DEL /Q /F "%DEST%\firefox10.7z"
|
|
IF EXIST "%DEST%\firefox9.7z" REN "%DEST%\firefox9.7z" firefox10.7z
|
|
IF EXIST "%DEST%\firefox8.7z" REN "%DEST%\firefox8.7z" firefox9.7z
|
|
IF EXIST "%DEST%\firefox7.7z" REN "%DEST%\firefox7.7z" firefox8.7z
|
|
IF EXIST "%DEST%\firefox6.7z" REN "%DEST%\firefox6.7z" firefox7.7z
|
|
IF EXIST "%DEST%\firefox5.7z" REN "%DEST%\firefox5.7z" firefox6.7z
|
|
IF EXIST "%DEST%\firefox4.7z" REN "%DEST%\firefox4.7z" firefox5.7z
|
|
IF EXIST "%DEST%\firefox3.7z" REN "%DEST%\firefox3.7z" firefox4.7z
|
|
IF EXIST "%DEST%\firefox2.7z" REN "%DEST%\firefox2.7z" firefox3.7z
|
|
IF EXIST "%DEST%\firefox1.7z" REN "%DEST%\firefox1.7z" firefox2.7z
|
|
|
|
%ZIP% a -t7z -mx1 "%DEST%\firefox1.7z" "%FFPROFILE%\*" -x!key3 -x!Cache -x!OfflineCache -x!mozilla-media-cache -x!*.corrupt
|