function script:filename([string] $path) { return [System.IO.Path]::GetFileName($path) } function stars { return (new-object string ('*', 80)) } $BASE = 'g:\backups' $today = [datetime]::Today.ToString("yyyyMMdd"); $dest = "$BASE\$today" $log = "$dest\log.txt" if ( -not (test-path $dest) ) { mkdir $dest } # # write header # write (stars) >> $log write "Backup procedure starting at " ` ([datetime]::Now.ToString()) >> $log write (stars) "`r`n`r`n" >> $log # # stop CVS services # net stop cvsnt >> $log net stop cvslock >> $log # # backup our set of folders # $folders = ( ('e:\CVS', ''), ('e:\devdeo', ''), ('e:\home', '*.swp'), ('e:\projects', '*.swp *.obj *.exe *.dll *.pdb *.pch *.idb'), ('e:\opensource', '*.swp *.obj *.exe *.dll *.pdb *.pch *.idb'), ('e:\tools', '') ) $folders | %{ $name = filename($_[0]) $excludes = $_[1].Split(' ') robocopy $_ "$dest\$name" *.* /E /ZB /NP /XF $excludes >> $log } # # backup our VPC data file # robocopy 'E:\vpc\' $dest 'datos.vhd' /NP >> $log # # restart CVS services # net start cvsnt >> $log net start cvslock >> $log # # write footer # write "`r`n`r`n" (stars) >> $log write "Backup procedure finished at " ` ([datetime]::Now.ToString()) >> $log write (stars) >> $log write "Backup done. Check log file for details." write $log