Created
December 26, 2024 21:36
-
-
Save ZSendokame/8b2f58c4b11b9d3d69abacb95cd72bc3 to your computer and use it in GitHub Desktop.
The simplest backup script for personal uses, feel free to modify.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # WARNINGS AND WORKINGS: | |
| # The script can be downloaded anywhere, but if there is no folder named as defined in $backupFolder, then it will create it. | |
| # BEFORE running the script, add the folders to backup in the $folders array. | |
| # To execute backup.ps1, calling it from a PowerShell session is enough (.\backup.ps1). | |
| # Useful variables to modify and/or use. | |
| $backupFolder = ".\backup" | |
| $desktop = [Environment]::GetFolderPath("Desktop") | |
| $folders = @() | |
| # File matching, feel free to add or modify. | |
| $files = foreach($folder in $folders) { | |
| (Get-ChildItem "$folder/*.json").FullName | |
| } | |
| if(-not (Test-Path $backupFolder)) { | |
| New-Item -ItemType Directory -Path $backupFolder | |
| } | |
| foreach($file in $files) { | |
| $itemName = (Get-Item $file).Name | |
| Copy-Item -Path $file -Destination "$backupFolder\$itemName" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment