Skip to content

Instantly share code, notes, and snippets.

@Kaapiii
Created September 25, 2018 14:13
Show Gist options
  • Save Kaapiii/a68a9a75e82dd0dcacea54217c8c2e67 to your computer and use it in GitHub Desktop.
Save Kaapiii/a68a9a75e82dd0dcacea54217c8c2e67 to your computer and use it in GitHub Desktop.
Backup files by filter from source directory and copy them to a new folder prfixed with the current date
$backupSourcePath = 'C:\Test\Source'
$backupDestPath = 'C:\Test\Dest'
$currentBackupDir = New-Item -ItemType Directory -Path "$backupDestPath\$((Get-Date).ToString('yyyy-MM-dd'))"
Get-ChildItem -Path "$backupSourcePath\*" -Include *.txt,*.db,*.log -Recurse | Copy-Item -Destination $currentBackupDir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment