-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrclone-backup.bat
34 lines (22 loc) · 1.03 KB
/
rclone-backup.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
@echo off
REM SET THE ZIP PROGRAM, WE USE 7ZIP to Compress the Folder
SET ZIPPRO="c:\Program Files\7-Zip\7z.exe"
REM SET THE ACCOUNTING DIRECTORY FOR BACKUP
SET ACCDIR="C:\Accounting"
REM Backup to Google Drive with rclone
SET REMOTEBACKUPDIR=GDrive:AccountingBackup\%dtStamp%\
REM Set the datetime format to readable format.
SET HOUR=%time:~0,2%
SET dtStamp9=%date:~-4%%date:~4,2%%date:~7,2%_0%time:~1,1%%time:~3,2%%time:~6,2%
SET dtStamp24=%date:~-4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%%time:~6,2%
if "%HOUR:~0,1%" == " " (SET dtStamp=%dtStamp9%) else (SET dtStamp=%dtStamp24%)
REM change to rclone directory
cd C:\rclone
echo "Compressing the backup files"
REM Start to zip the folder
%ZIPPRO% a -t7z Backup.%dtStamp%.7z %ACCDIR% -ssw >> c:\rclone\logfile.txt 2>&1
echo "Backup compress files into Google Drive"
REM Copy the files to Google Drive
rclone.exe -vvvvv sync Backup.%dtStamp%.7z %REMOTEBACKUPDIR% >> c:\rclone\logfile.txt 2>&1
REM Delete the file after backup
del Backup.%dtStamp%.7z >> c:\rclone\logfile.txt 2>&1