-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathBackup-ProgramsData.ps1
94 lines (89 loc) · 3.63 KB
/
Backup-ProgramsData.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
. .\utils.ps1
$PathPatternsOfProgramsDataToBackup = @{
"Primary" = @(
# Firefox
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\extension-preferences.json"
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\extensions"
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\extensions.json"
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\favicons.sqlite"
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\formhistory.sqlite"
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\places.sqlite"
"$Env:AppData\Mozilla\Firefox\installs.ini"
"$Env:AppData\Mozilla\Firefox\profiles.ini"
# Foobar2000
"$Env:AppData\foobar2000\*.sf*"
"$Env:AppData\foobar2000\configuration"
"$Env:AppData\foobar2000\theme.fth"
"$Env:AppData\foobar2000\user-components"
# Notepad++
"$Env:AppData\Notepad++\config.xml"
"$Env:AppData\Notepad++\plugins"
"$Env:AppData\Notepad++\themes"
"$Env:ProgramFiles\Notepad++\plugins"
# QuickLook
"$Env:AppData\pooi.moe\QuickLook\QuickLook.Plugin"
# Traffic Monitor
"$Env:AppData\TrafficMonitor\config.ini"
"$Env:LocalAppData\TrafficMonitor\global_cfg.ini"
"$Env:LocalAppData\TrafficMonitor\plugins"
# XnView MP
"$Env:AppData\XnViewMP\xnview.ini"
# rclone
"$Env:AppData\rclone\rclone.conf"
# qBittorrent
"$Env:AppData\qBittorrent\qBittorrent.ini"
)
"Secondary" = @(
# Firefox
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\cookies.sqlite"
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\permissions.sqlite"
"$Env:AppData\Mozilla\Firefox\Profiles\*.*\sessionstore.jsonlz4"
# FreeFileSync
"$Env:AppData\FreeFileSync"
# Foobar2000
"$Env:AppData\foobar2000\index-data"
"$Env:AppData\foobar2000\playlists-v*"
# Google Assistant
"$Env:AppData\Google Assistant\client_secret_*.apps.googleusercontent.com.json"
"$Env:AppData\Google Assistant\config.json"
"$Env:AppData\Google Assistant\tokens.json"
# Line
"$Env:LocalAppData\LINE\Data"
# Notepad++
"$Env:AppData\Notepad++\backup"
"$Env:AppData\Notepad++\session.xml"
# SoundSwitch
"$Env:AppData\SoundSwitch\SoundSwitchConfiguration.json"
# qBittorrent
"$Env:AppData\qBittorrent\categories.json"
"$Env:AppData\qBittorrent\qBittorrent-data.ini"
"$Env:LocalAppData\qBittorrent\BT_backup"
# Start Menu
"$Env:LocalAppData\Packages\Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy\LocalState\start*.bin"
)
}
function Get-BackupPath {
param (
[Parameter(Mandatory = $true)][string]$Path
)
$BackupsPath = "$PSScriptRoot\..\Backups"
if ($Path.StartsWith("$Env:AppData\")) {
return $Path.Replace("$Env:AppData\", "$BackupsPath\%AppData%\")
}
if ($Path.StartsWith("$Env:LocalAppData\")) {
return $Path.Replace("$Env:LocalAppData\", "$BackupsPath\%LocalAppData%\")
}
if ($Path.StartsWith("$Env:ProgramFiles\")) {
return $Path.Replace("$Env:ProgramFiles\", "$BackupsPath\%ProgramFiles%\")
}
if ($Path.StartsWith("${Env:ProgramFiles(x86)}\")) {
return $Path.Replace("${Env:ProgramFiles(x86)}\", "$BackupsPath\%ProgramFiles(x86)%\")
}
}
Get-Item $PathPatternsOfProgramsDataToBackup[$Args[0]] -ErrorAction "SilentlyContinue" |
ForEach-Object {
if ($_.DirectoryName -ne $null) {
New-Item (Get-BackupPath $_.DirectoryName) -ItemType Directory -Force
}
Copy-Item $_.FullName (Get-BackupPath $_.FullName) -Recurse -Force
}