|
|
@ -3,21 +3,16 @@ import { Writer } from 'clitastic'
|
|
|
|
import { config, VERBOSE } from './autorestic'
|
|
|
|
import { config, VERBOSE } from './autorestic'
|
|
|
|
import { getEnvFromBackend } from './backend'
|
|
|
|
import { getEnvFromBackend } from './backend'
|
|
|
|
import { Locations, Location } from './types'
|
|
|
|
import { Locations, Location } from './types'
|
|
|
|
import { exec, ConfigError } from './utils'
|
|
|
|
import { exec, ConfigError, pathRelativeToConfigFile } from './utils'
|
|
|
|
import { CONFIG_FILE } from './config'
|
|
|
|
|
|
|
|
import { resolve, dirname, isAbsolute } from 'path'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export const backupSingle = (name: string, from: string, to: string) => {
|
|
|
|
export const backupSingle = (name: string, from: string, to: string) => {
|
|
|
|
if (!config) throw ConfigError
|
|
|
|
if (!config) throw ConfigError
|
|
|
|
const writer = new Writer(name + to.blue + ' : ' + 'Backing up... ⏳')
|
|
|
|
const writer = new Writer(name + to.blue + ' : ' + 'Backing up... ⏳')
|
|
|
|
const backend = config.backends[to]
|
|
|
|
const backend = config.backends[to]
|
|
|
|
|
|
|
|
|
|
|
|
// Check if is an absolute path, otherwise get the path relative to the config file
|
|
|
|
const path = pathRelativeToConfigFile(to)
|
|
|
|
const pathRelativeToConfigFile = isAbsolute(from)
|
|
|
|
|
|
|
|
? from
|
|
|
|
|
|
|
|
: resolve(dirname(CONFIG_FILE), from)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const cmd = exec('restic', ['backup', pathRelativeToConfigFile], {
|
|
|
|
const cmd = exec('restic', ['backup', path], {
|
|
|
|
env: getEnvFromBackend(backend),
|
|
|
|
env: getEnvFromBackend(backend),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|