Su's Blog

Kratos
专注于用户阅读体验的响应式博客主题
  1. Main page
  2. Uncategorized
  3. Main content

自动备份quickbooks脚本,保留10份

June 3, 2026 6hotness 0likes 0comments

@echo off
setlocal enabledelayedexpansion
set BACKUP=D:\backup
set TMP=D:\QB_TMP
set SRC=SharedFiles\Quickbooks DATA
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd_HHmmss"') do set DT=%%i
set ZIP=%BACKUP%\backup_%DT%.zip
if not exist "%TMP%" mkdir "%TMP%"
if not exist "%BACKUP%" mkdir "%BACKUP%"
echo =====================================
echo 1. Create VSS snapshot
echo =====================================
(
echo SET CONTEXT PERSISTENT NOWRITERS
echo ADD VOLUME D: ALIAS QBVOL
echo CREATE
echo EXPOSE %%QBVol%% X:
) > "%TMP%\vss.txt"
diskshadow /s "%TMP%\vss.txt"
echo =====================================
echo 2. Copy from VSS (X:)
echo =====================================
robocopy "X:\%SRC%" "%TMP%" *.qbw* /R:1 /W:1
echo =====================================
echo 3. Remove snapshot (safe)
echo =====================================
echo DELETE SHADOWS ALL > "%TMP%\vss_del.txt"
diskshadow /s "%TMP%\vss_del.txt"
echo =====================================
echo 4. Compress with PowerShell
echo =====================================
powershell -NoProfile -Command ^
"Compress-Archive -Path '%TMP%\*' -DestinationPath '%ZIP%' -Force"
echo =====================================
echo 5. Cleanup temp
echo =====================================
rmdir /s /q "%TMP%"
echo =====================================
echo 6. Keep last 10 backups
echo =====================================
cd /d "%BACKUP%"
for /f "skip=10 delims=" %%f in ('dir backup_*.zip /b /o-d') do ( del "%%f"
)
echo DONE
endlocal

Tag: Nothing
Last updated:June 3, 2026

Su

This person is a lazy dog and has left nothing

Like
< Last article

COPYRIGHT © 2024 Su's Blog. ALL RIGHTS RESERVED.

Theme Kratos Made By Seaton Jiang

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.