Sie sind auf Seite 1von 2

An example batch for backups for a computer with two hard disks using windows 1.

Decalre variables for folders 2.Delete old content in backup folder (for loop) where the zip-archives will be stored 3.enter 7-zip-main-folder 4.use 7.exe command line tool to archive some files and folders (example here Documents, studies adn savegames and picdtures 5.for savegames this batch uses robocopy for incremental backups, the rest documents and studies and the content transferred from the other pc are backuped in their entirety 6.a for loop deletes old contents on T: (a USB flash drive) 7.robocopy is used to copy the files i want to backup from the remote pc in the same LAN. Its address is 192.168.130.3. Remote file transfer is easy with robocopy, just ensure that the network drive is accessible from both pcs so you dont get any errors. 8.i do incremental backups for the remote pc since i dont want to copy everything over the network whenever i run this code. 9.robocopy is on board on vista and 7. for XP, robocopy is not available but can be downloaded as an extra tool here: http://www.microsoft.com/enus/download/details.aspx?id=17657

@echo off set set set set set dir="c:\Backup-upload\" dir2="T:\Backups\Admin" dir3="\\192.168.130.3\Backups" dir4=c:\Backup-upload\PC2" delay=127.255.255.254

for /R %dir% %%f in (*.7z *.gpg) do ( del %%f ) cd /d g:\7-zip\ 7z.exe a -t7z "c:\Backup-upload\documents-backup-upload.%date%.7z" g:\Documents -mx=9 echo. echo The folder has been archived and saved to C:\Backup-upload echo. 7z.exe a -t7z "c:\Backup-upload\studies-backup-upload.%date%.7z" "g:\Uni" -mx=9 echo. echo The folder has been archived and saved to C:\Backup-upload echo. 7z.exe a -t7z "c:\Backup-upload\Batch-files-backup-upload.%date%.7z" "g:\BATCH-FILES" -mx=9 echo.

echo The folder has been archived and saved to C:\Backup-upload echo. robocopy "c:\Program Files (x86)\Game\data\savegames" "g:\Savegamescopy" /MAXAGE:20080701 7z.exe a -t7z "c:\Backup-upload\Savegames-backup-upload.%date%.7z" "g:\Savegames-copy" -mx=9 echo. echo The folder has been archived and saved to C:\Backup-upload echo. cd /d "c:\Backup-upload for /R %dir2% %%e in (*.7z) do ( del %%e ) xcopy *.7z T:\Backups\Admin /F /C /Y cls echo List files in remote folder dir /b %dir3% ping -n 3 %delay% > nul robocopy \\pc2\Backups T:\Backups\PC2 /S /R:3 /W:3 /ETA /LOG+:c:\BackupUpload\log-remote-copy.txt /NJH /NP /NS /NC /TEE robocopy \\pc2\Backups C:\Backup-upload\PC2 /S /R:3 /W:3 /ETA /LOG+:c:\Backup-Upload\log-remote-copy.txt /NJH /NP /NS /NC /TEE echo Copy pictures this time? set /p type="(y/n)? " if %type%==y ( goto A ) else ( if %type%==n ( goto B)) :A robocopy \\pc2\Pics T:\Backups\PC2\Pics /S /R:3 /W:3 /ETA :B 7z.exe a -t7z "C:\Backup-upload\PC2-Docs-backup-upload.%date%.7z" "C:\Backup-upload\PC2" -mx=9 echo. echo The folder has been archived and saved to C:\Backup-upload echo. pause > nul exit

Das könnte Ihnen auch gefallen