It uses Robocopy as standard, or Powershell, to copy all the files and folders in the script folder to one or more targets. The files can be compressed with 7zip (no robocopy there and no exclusions). Tere are some Settings you can change in the Script.
If you have BackupSettings.json in the same folder as the Script, it will use the settings from there. If you don't have a BackupSettings.json, it will use the default settings from script.
- Make backup of all Files in contained folder, except exclusions...
- WindowsCronRegister-backup.ps1 can register the Script as a Windows Task, so it will run every day at the time you set in the Script.
- open powershell as administrator
- run
Set-ExecutionPolicy RemoteSigned
optional:
Get-ExecutionPolicy -list |% {Set-ExecutionPolicy -scope $_.scope remotesigned -force -ErrorAction SilentlyContinue}
this script set all scopes to remotesigned, but throws some errors, because not all scopes are available on all systems
- clone this repo
- right click on
backup.ps1
and selectProperties
- in the section
open with
, selectchange
- scroll down and choose
More apps
- scroll down and choose
Look for another app on this PC
- paste
C:\Windows\System32\WindowsPowerShell\v1.0
in adressfield and press enter
- select
PowerShell.exe
and choose open
{
"SourcePaths": [
"./",
"T:\\zz_bkp_setings_folder"
],
"makeNewFolderIfNotExist": true,
"TargetPaths": [
"T:\\myAppBackupFolder\\",
"T:\\myAppBackupFolder\\settings\\"
],
"global:debugTransScript": false,
"global:debug": false,
"UpdateVersion": 142,
"AdminRightsRequired": false,
"AllowUpdate": 1,
"UpdateFromPath": "https://raw.githubusercontent.com/vitalyruhl/Win-PS-Autobackuping/master",
"UpdateFile": "backup.ps1",
"UpdateVersionFile": "VersionSettings.json",
"Prefix": "",
"Sufix": "",
"CompressIntoTargetPaths": false,
"UseRobocopy": true,
"Parameter": "/J /MIR /R:2 /W:1 /NP /COMPRESS",
"Excludes": [
".git",
"node_modules",
"*RECYCLE.BIN",
"SystemVolumeInformation",
"RECYCLER"
],
"FileExcludes": [
"*xvba_debug.log",
"*RECYCLE.BIN",
"Thumbs.db"
]
}
you can use a local path to update your script:
"UpdateFromPath":"\\\\myserver\\ps-scripts\\Powerschell\\Backup",
all variables, not included in the BackupSettings.json will be set to the default values.
- 03.08.2021 Exclusion don't work with compressing -> its copy all files
- 18.09.2022 Add format-variables like %date% to the prefix and sufix on uses settings.json
- 18.09.2022 Add a function to delete old backups, helpfull on compresssed backups with suffixes and prefixes
- 18.09.2022 Add possibility to rename script, and backup them also (for use multiple script in same folder)
- 18.09.2022 Register the script as a windows task must be changed for every script you need. It need a Refactoring to the backup.ps1 to run it over settings.json, or command parameter.
- 16.04.2023 Add updatesupport for Script without backupSettings.json and witoout settings overriden in the script
- 16.04.2023 correct parameter. On this time are excludes folder only, add /XF for files
- 16.04.2023 remove old copy, use only robocopy.
- 12.08.2023 BUG: copy from or into a folder with whitespaces and ÜÖÄ will don't work
-
12.08.2023 - Bugfix: Rename UseCoherentBackup Parameter - its confuse and make some deleteon on target.
"makeNewFolderIfNotExist": true,
-
"makeNewFolderIfNotExist": true --> (default) means, that first sourse will be copied to first target,second source to second target and so on. And a new folder with the last source folder will be created on the Target Path.
-
"makeNewFolderIfNotExist": false --> means, that all sources will be copied to all targets. AND in this Option, all files in the target will be deleted, if they are not in the source. Be careful with this option and make tests!!!.
-
12.08.2023 - Bugfix: Excludes (Files) - Add a new Parameter FileExcludes to prevent double excludes /XD + /XF
"FileExcludes": [ "*xvba_debug.log", "*RECYCLE.BIN", "Thumbs.db" ]
- 07.08.2023 - Bugfix: Excludes (Files) don't work
-
16.04.2023 - Add multiple source and target support
New Parameter in BackupSettings.json:
"SourcePaths": [ "./", "C:\\Users\\vivil\\Pictures\\" ], "TargetPaths": [ "T:\\zz_bkp_Test1\\", "T:\\zz_bkp_Test2\\" ], "makeNewFolderIfNotExist": false,
Note in this case, all files in the target will be deleted, if they are not in the source. Be careful with this option and make tests!!!.
Example-2:
- If you want to backup the script folder and a folder with settings, you can use the following example:
- please note, that Excludes must be used for settings Folder, otherwise it will be deleted on every run, and copied new.
"SourcePaths": [ "./", "T:\\zz_bkp_setings_folder" ], "TargetPaths": [ "T:\\myAppBackupFolder\\", "T:\\myAppBackupFolder\\settings\\" ], "makeNewFolderIfNotExist": true,
if those parameters are not in the BackupSettings.json, the script will use the old Settings:
- SourcePaths: "./" (means the script folder)
- 19.09.2022 - Bugfix script crash on target with whitespaces
- 18.09.2022 - Bugfix on no internet connection
- 17.09.2022 - Add aditional transscript to togfile and download actual version from GitHub
- 13.09.2022 - Add aditional BackupSettings.json
- 13.09.2022 - Bugfix on source as drive like s:\
- 13.09.2022 - Add robocopy option
- 03.08.2021 - initial release
if you prefer a one-time donation | Become a patron, by simply clicking on this button (**very appreciated!**): |
2021-2023 (c)Vitaly Ruhl
License: GNU General Public License v3.0