Backup Script
Here's a simple backup script i use to backup my stuff to a external drive.
function xah-backup-drives { # .DESCRIPTION # backup my drives # Version 2021-03-30 2022-06-15 # .LINK # http://xahlee.info/powershell/powershell_backup_script.html Get-Date -Format "yyyy-MM-dd HH:mm" echo "Start backup" $xDate = Get-Date -Format "yyyy-MM-dd_HHmmss" $destDirPath = "f:/xahbackup_${xDate}" $null = mkdir $destDirPath echo "ssss---------------------------------------------------" Get-Date -Format "yyyy-MM-dd HH:mm" echo "Start backup xah website git" $xahWebGitBackupPath = Join-Path $destDirPath "xahweb_${xDate}.git.zip" $gitCommand = "git --git-dir='c:/Users/xah/web/.git/' archive -o '${xahWebGitBackupPath}' HEAD" Invoke-Expression $gitCommand echo "ssss---------------------------------------------------" Get-Date -Format "yyyy-MM-dd HH:mm" echo "Start backup c drive" $cDriveDirs = "xdoc", "git", "Desktop", "Documents" ; $cDriveDirs.foreach({ echo "zipping $_" 7z a (Join-Path $destDirPath "$_.7z") "c:/Users/xah/$_/" }) echo "ssss---------------------------------------------------" Get-Date -Format "yyyy-MM-dd HH:mm" echo "Start backup d drive" $dDriveDirs = "xah_ddrive_2022", "xah_archive"; $dDriveDirs.foreach({ echo "zipping $_" 7z a (Join-Path $destDirPath "$_.7z") "d:/$_/" }) echo "ssss---------------------------------------------------" Get-Date -Format "yyyy-MM-dd HH:mm" echo "Backup done." }