if there is an error while backing up, show it to the user

pull/23/head
cupcakearmy 5 years ago
parent 886b6362cd
commit d13d4f7cf1

@ -24,13 +24,15 @@ import {
export const backupFromFilesystem = (from: string, location: Location, backend: Backend, tags?: string[]) => { export const backupFromFilesystem = (from: string, location: Location, backend: Backend, tags?: string[]) => {
const path = pathRelativeToConfigFile(from) const path = pathRelativeToConfigFile(from)
const cmd = exec( const { out, err, status } = exec(
'restic', 'restic',
['backup', '.', ...getFlagsFromLocation(location, 'backup')], ['backup', '.', ...getFlagsFromLocation(location, 'backup')],
{ env: getEnvFromBackend(backend), cwd: path }, { env: getEnvFromBackend(backend), cwd: path },
) )
if (VERBOSE) console.log(cmd.out, cmd.err) if (VERBOSE) console.log(out, err)
if (status != 0 || err.length > 0)
throw new Error(err)
} }
export const backupFromVolume = (volume: string, location: Location, backend: Backend) => { export const backupFromVolume = (volume: string, location: Location, backend: Backend) => {
@ -44,6 +46,8 @@ export const backupFromVolume = (volume: string, location: Location, backend: Ba
execPlain(`docker run --rm -v ${volume}:/data -v ${tmp}:/backup alpine tar cf /backup/archive.tar -C /data .`) execPlain(`docker run --rm -v ${volume}:/data -v ${tmp}:/backup alpine tar cf /backup/archive.tar -C /data .`)
backupFromFilesystem(tmp, location, backend) backupFromFilesystem(tmp, location, backend)
} catch (e) {
throw e
} finally { } finally {
execPlain(`rm -rf ${tmp}`) execPlain(`rm -rf ${tmp}`)
} }

Loading…
Cancel
Save