Skip to content

Instantly share code, notes, and snippets.

@jessebutryn
Created August 18, 2020 17:33
Show Gist options
  • Select an option

  • Save jessebutryn/96f1741cab4f77b3e4f099f466b4738c to your computer and use it in GitHub Desktop.

Select an option

Save jessebutryn/96f1741cab4f77b3e4f099f466b4738c to your computer and use it in GitHub Desktop.
file backup script
$sdirs = @(
"C:\Users\jesse_b"
#"C:\Users\jesse_b\tmp"
)
$ddir = "Y:\jesse"
#$ddir = "C:\Users\jesse_b\tmp\test"
function fsync ($source,$target) {
$sourceFiles = @(Get-ChildItem -Path $source -Recurse | select -expand FullName)
foreach ($f in $sourceFiles) {
$destFile = $f.Replace($source,$target)
$exist = Test-Path -LiteralPath $destFile
if ($exist -eq $false) {
Copy-Item -LiteralPath "$f" -Destination "$destFile"
}
}
}
foreach ($e in $sdirs) {
fsync $e $ddir
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment