My useful Restic scripts
- Restic-Scripts
I use the extension Ludusavi Restic Playnite Plugin
to backup my save game with Restic after my playing session.
But, I got a lot of snapshots for my games, and my repository took 12 GiB on my computer.
I decided to clean my repository for a specific game, and I wrote the script Clean-Restic
to do it automatically.
I will describe each scripts. At the moment, there is this script available only:
- Clean-Restic
- Get-ResticGameSnapshots
This script is on beta:
- Remove-ResticSnapshots
I plan to do this script (not exhaustive):
- Restore-ResticSnapshot
This script help me to list my Restic snapshot for a specific game. You don't have to know the tag in Restic, it will list you unique game tag at the beginning. You have two optional parameters:
- Game (string): let you set the game that you want to show snapshots details. If you are wrong on the game name, an error message will appear and stop.
- Listing (switch): only list snapshots and quit
You can use PowerShell cmdlets (
Select-Object
,Sort-Object
,Format-*
andWhere-Object
) to filter precisely. - CountOnly (switch): only show a list of game with their number of snapshots.
You can use PowerShell cmdlets (
Select-Object
,Sort-Object
,Format-*
andWhere-Object
) to filter precisely.
Use Get-Member
to get available properties
You can use the common parameters of PowerShell (-Debug, -Verbose, etc.).
The Get-Help command works too:
Get-Help .\Get-ResticGameSnapshots.ps1
The script will generate a log file for each run and show you at the end the list of snapshot for the game you choose. Example:
Snapshot for Project Zomboid
Number ShortId DateTime Tags TotalFileBackup TotalFileSize
------ ------- -------- ---- --------------- -------------
1 5ac74d19 5/6/2023 10:44:16 AM stopped 20163 196.84 MiB
2 b57496b0 5/8/2023 10:59:39 AM stopped 20711 205.93 MiB
3 5ad0f356 5/9/2023 2:56:06 PM stopped 20998 210.37 MiB
4 3a7ebf3f 5/10/2023 11:53:50 AM stopped 22689 226.07 MiB
5 6888df0a 5/10/2023 11:56:52 AM stopped 22689 226.07 MiB
Action on snapshot
What would like to do with snapshots?
[C] Clean [D] Delete [Q] Quit [?] Help (default is "C"):
After this list, you can choose to clean snapshots (call Clean-Restic.ps1
for you after three questions) or remove one/some.
You have the option to delete snapshots, but this not completely implemented right now!
This script has only been testing with:
- PowerShellCore
- Restic
The most important part of this Readme!
- Download all the files and folders, and put it in folder of your choice and create a folder named
logs
if necessary - Run the script in a PowerShell console! At the the first run, the script will ask you a couple of questions to create all the settings.1
- Complete example for Weed Shop 3
.\Get-ResticGameSnapshots.ps1 | Format-Table -Autosize
- Example for V Rising 2 3
.\Get-ResticGameSnapshots.ps1 -Game "V Rising"
- Shows the 10 games with the most snapshots 4
.\Get-ResticGameSnapshots.ps1 -CountOnly | Sort-Object Snapshots | Select-Object -Last 10
- Complete demo of getting snapshots and cleaning them for Hogwarts Legacy FR / EN
This first script help me to clean my Restic repository for a specific game. It takes at least the game name as parameter. This parameter is used to filter Restic snapshots by tag. You have four more optional parameters:
- IncludeTag (string[]): Let you filter the snapshots of the game (eg: gameplay, manual). Take all snapshots that have tag1 or tag2, etc.
- ExcludeTag (string[]): Exclude snapshots that have the tag tag1 or tag2, etc.
- SnapshotToKeep (int): by default set in the setting file. You can specify how many snapshots you want to keep.
- NoDelete (switch): if you want to run the script without delete any snapshots, like a dry run.
- NoStats (switch): if you don't want the script show you the stats about your repository
You can also use the common parameters of PowerShell (-Debug, -Verbose, etc.).
The Get-Help command works too:
Get-Help .\Clean-Restic.ps1
The script will generate a log file for each run and show you at the end the stats before and after the run (unless you specified the NoStats
parameter).
Example:
Snapshot numbers: 311 / 275
Total files backup: 62980 / 54042
Total files size: 85.78 GB / 27.38 GB
Total blobs: 41806 / 26232
Total blobs size: 12.23 GB / 4.87 GB
Ratio: 14.26 % / 17.77 %
If you use the parameter NoDelete
you will only have the current stats of your repository.
Snapshot numbers: 275
Total files backup: 54042
Total files size: 27.38 GiB
Total blobs: 26232
Total blobs size: 4.87 GiB
Ratio: 17.77 %
This script has only been testing with:
- PowerShellCore
- Restic
Refer to Get-ResticGameSnapshots - How to use
-
.\Clean-Restic.ps1 -Game "V Rising"
5 Will clean snapshots for the game "V Rising" and keep the 5 latest snapshots -
.\Clean-Restic.ps1 -Game "Cyberpunk 2077" -SnapshotToKeep 1
Will clean snapshots for the game "Cyberpunk 2077" and keep the latest snapshot -
.\Clean-Restic.ps1 -Game "Raft" -SnapshotToKeep 10 -NoDelete
Will show you the snapshots that should be deleted -
.\Clean-Restic.ps1 -Game "Project Zomboid" -TagFilter "gameplay" -SnapshotToKeep 0
6 Will remove all the gameplay sansphots for Project Zomboid
This script is to remove a or some specific(s) snapshots.
It is not to replace Clean-Restic
, as this one, is to remove specific snapshots and Clean-Restic
to remove old ones.
- ShortIds (string[]): the short id to remove If you are wrong on the game name, an error message will appear and stop.
- NoDelete (switch): if you want to run the script without delete any snapshots, like a dry run.
- NoStats (switch): if you don't want the script show you the stats about your repository
This script has only been testing with:
- PowerShellCore
- Restic
Refer to Clean-Restic - How to use
Needs to be done