Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- setlocal
- REM This is a backup script I've designed solely for use with the Ditto clipboard manager.
- :: Instructions:
- :: To schedule this script to run monthly using the Windows Task Scheduler:
- :: 1. Open Task Scheduler.
- :: 2. Click "Create Basic Task..." in the Actions pane.
- :: 3. Name the task and provide a description, then click "Next".
- :: 4. Select "Monthly" and click "Next".
- :: 5. Set the desired start date_time and time, choose all of the months and the day, then click "Next".
- :: 6. Select "Start a program" and click "Next".
- :: 7. Click "Browse..." and select this script file.
- :: 8. Click "Next" and then "Finish".
- :: Paths
- set "DITTO_PATH=C:\Program Files\Ditto\Ditto.exe"
- set "DITTO_DB_PATH=%USERPROFILE%\AppData\Roaming\Ditto\Ditto.db"
- set "BACKUP_PATH=X:\Storage\Ditto"
- set "ZIP_EXE=C:\Program Files\7-Zip\7z.exe"
- set "PASSWORD=password123" || REM Set the 7-Zip password to encrypt the backups
- :: Disconnect and exit Ditto using command line
- "%DITTO_PATH%" /Disconnect
- timeout /t 3 /nobreak >nul
- "%DITTO_PATH%" /Exit
- :: Alert the user
- echo Ditto backup initiated. Do not use. This will only take a few seconds.
- timeout /t 10
- :: Close Ditto
- :waitloop
- taskkill /im Ditto.exe
- timeout /t 1 /nobreak >nul
- tasklist /fi "imagename eq Ditto.exe" | find /i "Ditto.exe" >nul
- if not errorlevel 1 (
- goto waitloop
- )
- :: Get the current date and time in YYYY-MM-DD_HH-MM format
- for /f "tokens=2 delims==." %%I in ('wmic OS Get localdatetime /value') do set DT=%%I
- set "DATE_TIME=%DT:~0,4%-%DT:~4,2%-%DT:~6,2%_%DT:~8,2%-%DT:~10,2%"
- :: Backup Ditto database file with password
- "%ZIP_EXE%" a -tzip -p%PASSWORD% "%BACKUP_PATH%\%DATE_TIME%.zip" "%DITTO_DB_PATH%"
- :: Check if backup was successful
- if exist "%BACKUP_PATH%\%DATE_TIME%.zip" (
- :: Delete the original database file
- del "%DITTO_DB_PATH%"
- timeout /t 10
- ) else (
- echo Backup failed, original file not deleted.
- pause
- exit /b 1
- )
- :: Reopen Ditto
- start "" "%DITTO_PATH%"
- timeout /t 3 /nobreak >nul
- "%DITTO_PATH%" /Connect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement