I want my PowerShell script to take a backup of $destination
directory, in $backup
directory, but the newly created backup directory should be named $destination-{yyyy-dd-mm}
where 'yyyy-dd-mm' is today's date.
I have written my 1st ever PowerShell script which accomplishes the job with one caeat. I have noticed that it creates a folder if it does not exist already and copies all the files into this folder the 1st time it is executed, but on subsequent runs it skips all files, if there is no change. I want to forcefully overwrite the destination files regardless of their last change date.
"START"
$source = "C:\Sandbox\Source"
$destination = "C:\Sandbox\Target"
$backup = "C:\Backups\"
"Taking backup of '$destination' in '$backup'"
$currentDate = Get-Date
$currentDate = $currentDate.ToString("yyyy-MM-dd")
$something = $backup + "Staging-" + $currentDate
robocopy $targetPath $something /E /V /MT /Z
"END"
copy
command.robocopy
is made for synching.