Skip to content

Instantly share code, notes, and snippets.

Created Aug 18, 2020
What would you like to do?
file backup script
$sdirs = @(
$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