# My Windows Backup Batch File

I’ve noticed that a couple of people have lost data recently. In case it helps anyone, here’s my personal Windows batch file for backing up Logseq data:

echo off
cls
@if exist z: net use z: /delete
start z:
echo Z drive active?
pause
echo on
cls
set name=%date:~-4,4%_%date:~3,2%_%date:~0,2%
set hr=%time:~0,2%
set hr=%hr: =0%
set min=%time:~3,2%
set name=%name%__%hr%%min%

md c:\temp\LogSeq

xcopy C:\Users\graham\.logseq\*.* c:\temp\LogSeq\dot\*.* /s /h
xcopy C:\Users\graham\Documents\logseq\*.* c:\temp\LogSeq\documents\logseq\*.* /s /h

RD /S /Q C:\Temp\LogSeq\dot\plugins
"C:\Program Files\7-zip\7z.exe" a c:\temp\%name%.zip C:\temp\LogSeq\* -r
RD /S /Q c:\temp\LogSeq
xcopy c:\temp\%name%.zip z:\LogSeq\*.*
del c:\temp\%name%.zip
start z:\logseq

Line 3 clears my Z: drive if it's in use

Line 4 assigns my Z: drive to the to my OneDrive folder (a cloud location that will still exist if something happens to my local data or computer)

Line 5 opens Z: in the Windows file manager

Line 7 pauses so that I can check that the assignment is correct

Lines 10-14 make a unique file name based on the date and time

Lines 16-19 copy my Logseq data to a temporary folder

Line 21 removes the plugins folder from the temporary folder (I have no need to backup plugins)

Line 22 uses 7-zip (which you'll need to install) to form the backup data into a single compressed Zip file

Line 24 copies the Zip file to my Z: drive

Lines 23 and 25 tidy up (remove the backup folders from my PC)

Line 26 opens the cloud backup location in Windows Explorer so that I can see that everything has worked

2 Likes

I now backup by copying the folder of my graph to my NAS and giving the folder there the name of the graph with a date marker. Can you tell me, what am I overlooking.