From 06ce8180fb4cd722770e9389e25c6e938a5cb97f Mon Sep 17 00:00:00 2001 From: cupcakearmy Date: Sat, 26 Oct 2019 21:50:48 +0200 Subject: [PATCH] support for absolute paths --- src/backup.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backup.ts b/src/backup.ts index 7d0c7a2..bfdd837 100644 --- a/src/backup.ts +++ b/src/backup.ts @@ -5,13 +5,17 @@ import { getEnvFromBackend } from './backend' import { Locations, Location } from './types' import { exec, ConfigError } from './utils' import { CONFIG_FILE } from './config' -import { resolve, dirname } from 'path' +import { resolve, dirname, isAbsolute } from 'path' export const backupSingle = (name: string, from: string, to: string) => { if (!config) throw ConfigError const writer = new Writer(name + to.blue + ' : ' + 'Backing up... ⏳') const backend = config.backends[to] - const pathRelativeToConfigFile = resolve(dirname(CONFIG_FILE), from) + + // Check if is an absolute path, otherwise get the path relative to the config file + const pathRelativeToConfigFile = isAbsolute(from) + ? from + : resolve(dirname(CONFIG_FILE), from) const cmd = exec('restic', ['backup', pathRelativeToConfigFile], { env: getEnvFromBackend(backend),