记录一下我的云端备份脚本

rem set ENV
path %PATH%;c:\progra~1\winrar\
path %PATH%;c:\windows\system32
path %PATH%;C:\green\rclone\
rem BACKUP NOW
set backupSource=c:\gitresp\
set backupPath=C:\OneDri~1.abc\vps.qc\git\
set fileName=gitbak_%date:~0,4%%date:~5,2%%date:~8,2%
set fullFileName=%backupPath%%fileName%.rar
echo %fullFileName%
rar a %fullFileName% %backupSource% -r
echo %fullFileName%
rem REMOVE OLD ARCHIVE
cd %backupPath%
forfiles /D -7 /c "cmd /c del /Q @file"
rem SYNC
rclone sync %backupPath% onedrive:backup\git\

计划任务,定期执行,将指定的目录(backupSource)通过rar(需要先安装winrar或其它命令行)压缩为gitbak_年份日期.rar的名称,并放到backupPath目录下。

执行forfiles删除7天外的文件。

执行rclone(需要事先下载rclone并配置相应的OneDrive的登录信息),将相应的备份目录,同步到云端的指定目录(backup\git)。

先通过Path命令添加winrar,rclone等执行文件目录。

You may also like

Leave a Reply

Your email address will not be published. Required fields are marked *