8 Commits
Author SHA1 Message Date
sugoidogo 3f2d3101c7 correct permissions before launch for misbehaving services
Main / release (push) Successful in 53s
2026-01-14 06:05:49 -08:00
sugoidogo bb3c0e5c13 remove redundant command (i misunderstood the event)
Main / release (push) Successful in 41s
2026-01-14 05:34:29 -08:00
sugoidogo e70655189c remove unused import 2026-01-14 03:41:33 -08:00
sugoidogo 0a01666de3 disable dbus to prevent timeout errors
Main / release (push) Successful in 41s
2026-01-14 03:05:00 -08:00
sugoidogo 458105e611 grant full env permissions
Main / release (push) Successful in 41s
2026-01-14 01:12:45 -08:00
sugoidogo 8549cfd4da always write index
Main / release (push) Successful in 43s
2026-01-14 01:10:16 -08:00
sugoidogo 81086a7628 undo log-to-file changes 2026-01-14 01:10:02 -08:00
sugoidogo 02ff1b58f7 try to fix logging again
Main / release (push) Successful in 41s
2026-01-14 00:57:44 -08:00
3 changed files with 6 additions and 36 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
"read": true,
"write": true,
"run": ["tar","chmod"],
"env": ["CLICOLOR_FORCE"]
"env": true
}
}
}
+2 -33
View File
@@ -7,26 +7,11 @@ import path from "node:path"
import strftime from 'strftime'
import { spawnSync } from "node:child_process"
const logfd = fs.openSync('/etc/snapback/log.txt', 'w')
function logToFile() {
// Source - https://stackoverflow.com/a/35542360
// Posted by Anatol - user3173842
// Retrieved 2026-01-14, License - CC BY-SA 3.0
var access = fs.createWriteStream('',{'fd':logfd});
process.stdout.write = process.stderr.write = access.write.bind(access);
process.on('uncaughtException', function (err) {
console.error((err && err.stack) ? err.stack : err);
});
}
let config: { [key: string]: string|undefined } = {}
let index: { [key: string]: { [key: string]: string|undefined }|undefined } = {}
function sugoiSpawn(...command: string[]) {
const result = spawnSync(command.shift()!, command, { stdio: ['ignore',logfd,logfd] })
const result = spawnSync(command.shift()!, command, { stdio: 'inherit' })
if (result.error) throw result.error
if (result.status !== 0) process.exit(result.status)
return result
@@ -71,7 +56,6 @@ program.command('install').description('installs snapback on your system')
program.command('create-snapshot-post <subvolume> <fstype> <number>')
.description('create a backup after a snapshot')
.action(function (subvolume, fstype, number) {
logToFile()
if (!config[subvolume]) {console.log(subvolume + ' not configured for snapback'); return}
const destination = strftime(config[subvolume])
const dirname = path.dirname(destination)
@@ -89,7 +73,6 @@ program.command('create-snapshot-post <subvolume> <fstype> <number>')
program.command('delete-snapshot-post <subvolume> <fstype> <number>')
.description('delete a backup after deleting a snapshot')
.action(function (subvolume, fstype, number) {
logToFile()
if (!index[subvolume]) {
console.log('no backups indexed for ' + subvolume)
return
@@ -104,20 +87,6 @@ program.command('delete-snapshot-post <subvolume> <fstype> <number>')
console.log('deleted backup at '+destination)
})
program.command('delete-config-post <subvolume> <fstype>')
.description('delete metadata of deleted subvolume, retaining backups')
.action(function (subvolume, fstype) {
logToFile()
delete index[subvolume]
if (!config[subvolume]) {
console.log(subvolume + ' not configured for snapback')
return
}
const destination = strftime(config[subvolume])
const dirname = path.dirname(destination)
console.log('existing backups remain at '+dirname)
})
program.parse()
if (Object.keys(index).length) fs.writeFileSync(program.opts().indexFile,stringifyJSON(index), 'utf8')
fs.writeFileSync(program.opts().indexFile,stringifyJSON(index), 'utf8')
+3 -2
View File
@@ -1,5 +1,6 @@
[Service]
Type=exec
ExecStartPre=-btrfs subvolume create %I
ExecStartPre=-snapper --config %i create-config --template snapback %I
ExecStart=snapper --config %i create --cleanup-algorithm number
ExecStartPre=-snapper --no-dbus --config %i create-config --template snapback %I
ExecStartPre=chown 0 %I/.snapshots
ExecStart=snapper --no-dbus --config %i create --cleanup-algorithm number