Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e49b1d9a4b | ||
|
|
a8a23db940 | ||
|
|
c7443470a2 |
+1
-1
@@ -16,7 +16,7 @@ for (const target of targets) {
|
||||
sugoiSpawn('deno', 'compile',
|
||||
'--target', target,
|
||||
'--include', 'src/snapper-template.txt',
|
||||
'--include', 'src/snapper@.service',
|
||||
'--include', 'src/snapback@.service',
|
||||
'--output', 'dist/snapback-'+target,
|
||||
'--permission-set','src/main.ts'
|
||||
)
|
||||
|
||||
+12
-3
@@ -36,14 +36,18 @@ program.command('*').description('snapback ignores unknown commands')
|
||||
program.command('install').description('installs snapback on your system')
|
||||
.action(function () {
|
||||
const template = fs.readFileSync(import.meta.dirname + '/snapper-template.txt')
|
||||
const service = fs.readFileSync(import.meta.dirname + '/snapper@.service')
|
||||
const service = fs.readFileSync(import.meta.dirname + '/snapback@.service')
|
||||
let lib_snapper = '/usr/libexec/snapper'
|
||||
if (!fs.existsSync(lib_snapper)) lib_snapper = '/usr/lib/snapper'
|
||||
if (!fs.existsSync('/etc/snapper/config-templates')) fs.mkdirSync('/etc/snapper/config-templates')
|
||||
fs.writeFileSync('/etc/snapper/config-templates/snapback', template, 'utf8')
|
||||
fs.writeFileSync('/etc/systemd/system/snapper@.service', service, 'utf8')
|
||||
fs.writeFileSync('/etc/systemd/system/snapback@.service', service, 'utf8')
|
||||
fs.mkdirSync(lib_snapper + '/plugins', { recursive: true })
|
||||
fs.renameSync(import.meta.url, lib_snapper + '/plugins/99-snapback')
|
||||
let argv0 = process.argv0
|
||||
if (['node','deno','bun'].includes(path.basename(argv0).replace('.exe',''))) {
|
||||
argv0 = import.meta.url
|
||||
}
|
||||
fs.renameSync(argv0, lib_snapper + '/plugins/99-snapback')
|
||||
sugoiSpawn('chmod', '+x', lib_snapper + '/plugins/99-snapback')
|
||||
console.log('snapback installed')
|
||||
})
|
||||
@@ -61,6 +65,7 @@ program.command('create-snapshot-post <subvolume> <fstype> <number>')
|
||||
'--auto-compress', '--dereference', '.'
|
||||
)
|
||||
index[subvolume][number] = destination
|
||||
console.log('created backup at '+destination)
|
||||
})
|
||||
|
||||
program.command('delete-snapshot-post <subvolume> <fstype> <number>')
|
||||
@@ -69,12 +74,16 @@ program.command('delete-snapshot-post <subvolume> <fstype> <number>')
|
||||
const destination = index[subvolume][number]
|
||||
fs.unlinkSync(destination)
|
||||
delete index[subvolume][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) {
|
||||
delete index[subvolume]
|
||||
const destination = strftime(config[subvolume])
|
||||
const dirname = path.dirname(destination)
|
||||
console.log('existing backups remain at '+dirname)
|
||||
})
|
||||
|
||||
program.parse()
|
||||
|
||||
Reference in New Issue
Block a user