Microsoft/Windows/backups

from HTYP, the free directory anyone can edit if they can prove to me that they're not a spambot
< Microsoft‎ | Windows
Revision as of 21:20, 14 August 2021 by Woozle (talk | contribs) (Woozle moved page Microsoft Windows/backups to Microsoft/Windows/backups)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

batch scripts with journaling

One dead simple, non-proprietary way of making backups from a Windows system to a network share (or secondary storage) is using batch files. This should work with anything from Win98 (when the Task Scheduler first appeared, iirc) through Vista, though I have only tested it with Win98.

This sets up a set of journals by day and by month, so that you can recover old versions of files. (This is useful in case a file gets clobbered somehow but you only notice the problem after it is backed up.)

You simply create a batch file to do the backup, and then use the Task Scheduler to run each batch file at appropriate intervals (after midnight on a Saturday works well):

backup.bat - generalized, with 5 journals labeled as "daily": <DOS> REM Shift journals forward xcopy /s/c/Y/d [target]\machines\[source_pc]\journal\5\*.* [target]\machines\[source_pc]\journal\6\ xcopy /s/c/Y/d [target]\machines\[source_pc]\journal\4\*.* [target]\machines\[source_pc]\journal\5\ xcopy /s/c/Y/d [target]\machines\[source_pc]\journal\3\*.* [target]\machines\[source_pc]\journal\4\ xcopy /s/c/Y/d [target]\machines\[source_pc]\journal\2\*.* [target]\machines\[source_pc]\journal\3\ xcopy /s/c/Y/d [target]\machines\[source_pc]\journal\1\*.* [target]\machines\[source_pc]\journal\2\ REM Backup from source xcopy /s/c/y/d [source_dir_1]\*.* [target]\machines\[source_pc]\journal\1\[target 1]\ xcopy /s/c/y/d [source_dir_1]\*.* [target]\machines\[source_pc]\journal\1\[target 2]\ REM ...and so on. </DOS>

  • [source_pc] is the name of the machine being backed up,
  • [source_dir_n] refers to each of the folders you would like to back up
  • [target] is the folder where you want to put all your backups
  • [target_n] is whatever you'd like to name [source_dir_n] within the backup

There's probably a way to do this more elegantly using batch %VARIABLES%, but I haven't had a chance to work out the details and test the results.

Example

from The Hypertwins' network:

daily backup.bat <DOS> REM Shift journals forward xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Daily\5\*.* \\rizzo\shared\backups\machines\vincent\Daily\6\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Daily\4\*.* \\rizzo\shared\backups\machines\vincent\Daily\5\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Daily\3\*.* \\rizzo\shared\backups\machines\vincent\Daily\4\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Daily\2\*.* \\rizzo\shared\backups\machines\vincent\Daily\3\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Daily\1\*.* \\rizzo\shared\backups\machines\vincent\Daily\2\ REM Backup from source xcopy /s/c/y/d c:\etc\work\*.* \\rizzo\shared\backups\machines\vincent\Daily\1\Work\ xcopy /s/c/y/d "c:\my documents\Digital Wave Player\*.*" \\rizzo\shared\backups\machines\vincent\Daily\1\Dictaphone\ xcopy /s/c/y/d "C:\My Documents\My PSP8 Files\*.*" \\rizzo\shared\backups\machines\vincent\Daily\1\PaintShop\ </DOS>

monthly backup.bat <DOS> REM Shift journals forward xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Monthly\5\*.* \\rizzo\shared\backups\machines\vincent\Monthly\6\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Monthly\4\*.* \\rizzo\shared\backups\machines\vincent\Monthly\5\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Monthly\3\*.* \\rizzo\shared\backups\machines\vincent\Monthly\4\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Monthly\2\*.* \\rizzo\shared\backups\machines\vincent\Monthly\3\ xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Monthly\1\*.* \\rizzo\shared\backups\machines\vincent\Monthly\2\ REM Shift oldest daily to first monthly xcopy /s/c/Y/d \\rizzo\shared\backups\machines\vincent\Daily\6\*.* \\rizzo\shared\backups\machines\vincent\Monthly\1\ </DOS>