ludusavi
ludusavi copied to clipboard
schedule backup feature
a handy feature for lazy people
scheduled backups with versioning would be very nice!
In case you are interested, I will share my personal solution for automatic backups. I use nssm (available via choco) This is a dump of the nssm service:
You will want to replace alima
with your username. If you use a local account replace "****" with your local password, if it's a microsoft account, use your Microsoft password, not your pin.
nssm.exe install ludusavi C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
nssm.exe set ludusavi AppParameters C:\Users\alima\AppData\Roaming\ludusavi\service.ps1
nssm.exe set ludusavi AppDirectory C:\Users\alima\AppData\Roaming\ludusavi
nssm.exe set ludusavi AppExit Default Restart
nssm.exe set ludusavi DisplayName ludusavi
nssm.exe set ludusavi ObjectName .\alima "****"
nssm.exe set ludusavi Start SERVICE_DELAYED_AUTO_START
nssm.exe set ludusavi Type SERVICE_WIN32_OWN_PROCESS
The service.ps1 is this:
$ludusaviPath = "C:\ProgramData\chocolatey\bin\ludusavi.exe"
$workingDir = "C:\Users\alima\AppData\Roaming\ludusavi"
$logFile = "$workingDir\ludusavi_service_log.txt"
$maxLogSize = 1MB
$arguments = " backup --try-update --force"
Set-Location "$workingDir"
Write-Output "We're good to go. starting loop..."
Start-Transcript -Path $logFile -Append
while ($true) {
Write-Output "=================================="
Write-Output "running backup at $(get-date)..."
Write-Output "=================================="
Invoke-Expression "$ludusaviPath $arguments"
Write-Output "=================================="
Write-Output "checking if log file needs to be rotated at $(get-date)..."
Write-Output "=================================="
# Check if log file has reached max size and delete old log file
if ((Get-Item $logFile).Length -gt $maxLogSize) {
Write-Output "log file has reached max size of $($maxLogSize/1MB)MB. rotating..."
Stop-Transcript
$oldLogFile = "$logFile.old"
if (Test-Path $oldLogFile) {
Remove-Item $oldLogFile
}
Start-Sleep 2
Move-Item $logFile $oldLogFile
Start-Transcript -Path $logFile -Append
}
Write-Output "sleeping for 12 hours"
Start-Sleep -Seconds $(60 * 60 * 12)
}
Stop-Transcript
I have put the file simply in %appdata%\ludusavi
that way it gets backed up like ludusavi itself, which I set up by adding it as a custom game (from %appdata%\ludusavi\config.yaml
):
customGames:
- name: ludusavi
files:
- "<winAppData>\\ludusavi\\cache.yaml"
- "<winAppData>\\ludusavi\\config.yaml"
- "<winAppData>\\ludusavi\\manifest.yaml"
- "<winAppData>\\ludusavi\\service.ps1"
registry: []
You want to create the service file, install nssm and change the nssm commands to use your paths/user. Then just run them and afterwards you should see a service called ludusavi. The service should start with windows and create a backup when it starts and then every 12 hours. The execution log will be saved to %appdata%\ludusavi\ludusavi_service_log.txt
. And it is made sure the logs never take up more than 2MB of space.
It would be really nice to have this integrated directly please.
this would be great. but also for the other OSen. i use linux my self and powershell is possible in linux but not standard installed.
this would be great. but also for the other OSen. i use linux my self and powershell is possible in linux but not standard installed.
@Nekotje The simplest solution would be a cron job (https://wiki.archlinux.org/title/cron#Basic_commands)
just run /path/to/ludusavi --try-manifest-update backup --force
for backup and /path/to/ludusavi cloud upload --force
for cloud upload