From d13d4f7cf1596b71065b1bd173f2ed01391ea3f2 Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Tue, 24 Dec 2019 18:42:09 +0100 Subject: [PATCH] if there is an error while backing up, show it to the user --- src/backup.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backup.ts b/src/backup.ts index 0f0b78e..ff5b4e5 100644 --- a/src/backup.ts +++ b/src/backup.ts @@ -24,13 +24,15 @@ import { export const backupFromFilesystem = (from: string, location: Location, backend: Backend, tags?: string[]) => { const path = pathRelativeToConfigFile(from) - const cmd = exec( + const { out, err, status } = exec( 'restic', ['backup', '.', ...getFlagsFromLocation(location, 'backup')], { 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) => { @@ -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 .`) backupFromFilesystem(tmp, location, backend) + } catch (e) { + throw e } finally { execPlain(`rm -rf ${tmp}`) }