TypechoJoeTheme

贰狐Blog - 一个笨蛋的博客

统计

贰狐

类目归类

Windows自动压缩文件夹,备份并上传到网盘

2019-12-09
/
0 评论
/
3,343 阅读
/
正在检测是否收录...
12/09
日常生活中有一些需要定期备份的bot目录,但是手动备份太麻烦了,如果用Windows的计划任务搭配bat脚本进行自动备份,并上传到网盘呢?

首先你需要有一个Onedrive或百度网盘。我比较推荐Onedrive是因为可以白嫖。当然,用百度网盘,然后设置某个目录为自动同步的文件夹也是可以的。

微软为每个账号提供空间为5GB的Onedrive,其实也够用了。

如果不够用可以白嫖↓

申请OneDrive 5T 网盘便民方法和邮箱
免费office365教育版A1子号(5Tonedrive网盘),可以自助申请

之后安装一下 7-ZipOnedrive

大功告成,然后复制下面的代码,按说明替换中间的目录,保存成auto_backup.bat

注意:所有目录中不得包含中文

@echo off
::设置7z的命令行程序路径
set zip7=C:\Program Files\7-Zip\7z.exe
::设置压缩包保存路径,即你的onedrive本地路径
set Save=D:\Onedrive\OneDrive - User\BMX_backup
::当天日期,备份文件名
set curdate=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
::设置要打包压缩的文件夹
set zipfile=D:\Mirai_bmx
 
::备份命令 -xr!.svn过滤\data\image\文件夹 mx0是存储模式压缩
"%zip7%" a -tzip "%Save%\cq_bmx_%curdate%.zip" "%zipfile%" -mx0 -xr"!*\data\image\"

::删除超过7天的备份--start--
forfiles /p "%Save%" /m *.zip -d -7 /c "cmd /c del /f @path"

到这里其实就可以直接设置计划任务,每天定时运行了

不过由于我这里需要对酷Q进行备份,运行中的程序是无法被压缩的。

并且程序长时运行也可能出现问题,所以我们做一个自动重启的步骤。

保存下列代码放在上述代码前面,用于强行结束Mirai(如果是骰子请设置自动保存,不然可能会丢失数据)。

C:\Windows\system32\taskkill.exe /f /im MiraiOK_windows_386.exe
C:\Windows\system32\taskkill.exe /f /im MiraiOK.exe
C:\Windows\system32\taskkill.exe /f /im java.exe</div>

如果是XQ的话,可以用,同样调用Taskkill,但是由于在某些系统上无法执行中文bat,所以需要加CHCP。不过XQ注意定时清理image目录,不然压缩时候会爆炸,几个G的图片在那压缩,可就麻烦了。

echo off
CHCP 65001
echo  -------------------------
echo  重启中,请稍后...
echo  -------------------------
C:\Windows\system32\taskkill.exe /f /im 先驱.exe
保存下列代码,替换目录成bot的启动快捷方式,用于在备份后顺序启动(而不是开备份脚本的同时就打开了bot)。就起名叫start_mirai.bat吧

start D:\Mirai_bmx\Mirai_bmx.lnk

之后给这两个bat做一个控制开关,复制并替换上面两个脚本的存放位置,起名叫switch_mirai.bat

C:/auto_backup/auto_backup.bat&&;C:/auto_backup/start_mirai.bat

然后将 switch_mirai.bat 放入计划任务或是启动项中

启动项目录可以通过Win+R打开[运行]后输入 shell:startup 来快速打开。

可以在Onedrive网页中将备份的目录设置为共享,这样就能在异地直接下载了!

参考资料
windows bat脚本7zip压缩文件夹,过滤文件夹 - 黑夜的白羊
如何设置2个bat文件严格按照顺序执行 - 百度知道

朗读
赞 · 1
版权属于:

贰狐Blog - 一个笨蛋的博客

本文链接:

https://www.aobacore.com/archives/83.html(转载时请注明本文出处及文章链接)

评论 (0)

贰狐

17 文章数
57 评论量
本站已存活

人生倒计时

今日已经过去小时
这周已经过去
本月已经过去
今年已经过去个月

最新回复

  1. 夏宇
    2022-04-11
  2. Aran
    2022-02-18
  3. 围今
    2022-02-06
  4. 54545
    2021-12-29

    {!{data:image/webp;base64,UklGRgoaAABXRUJQVlA4WAoAAAAwAAAAAQMAKwEASUNDUBgCAAAAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJ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r1eieJAmH7FABknroV6XmPb5MPQxb78f3LUcSce9sFSC5l95U8e/19uy1f1yCvesGVyHZuNcuFWBjb32o1iL4nTlrc4rg0LSwmiQl9/hdBTiy7KP3wiePGzViyICQnl0C2wW8+mJzP5/6dWtVr1TOeTVeDJ4ye/WuC3B89tt1SV7utkvFyQ/v3bpefOH08cN5+3bvtGakpiSuWbEkdsG8iNkLsjdmn4OTL33kTZJz12wtuO6Z7IyVISRDB+3Qn3M7ln8zsVeL6iRRv3FELy7sXPH1+B7+VUnKHrVk0eyIeQtil6xYk5iSmmHduXtf3uHjpy8UX79176EGLv6+6tvx3ZpVJom9XKXqterW9/Fr/uKrAe0Cu/QMGTBkxKhxk8Pf+yg6fWb3phXpsf8f+///0gdWUDgg0gEAAFA1AJ0BKgIDLAE/cbjZZbSvK6cgCAKQLglpbuF3YRtACewD32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ych77ZOQ99snIe+2TkPfbJyHvtk5D32ycKAAD+/60eAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=}!}

  5. 夏宇
    2021-12-25

标签云