Implement --suffix for use with --backup-dir only #98

This also makes sure we remove files we are about to override in the
--backup-dir properly.
This commit is contained in:
Nick Craig-Wood
2017-01-19 17:26:29 +00:00
parent a77659e47d
commit e2bf9eb8e9
5 changed files with 66 additions and 15 deletions

View File

@@ -87,6 +87,7 @@ var (
noTraverse = BoolP("no-traverse", "", false, "Don't traverse destination file system on copy.")
noUpdateModTime = BoolP("no-update-modtime", "", false, "Don't update destination mod-time if files identical.")
backupDir = StringP("backup-dir", "", "", "Make backups into hierarchy based in DIR.")
suffix = StringP("suffix", "", "", "Suffix for use with --backup-dir.")
bwLimit BwTimetable
// Key to use for password en/decryption.
@@ -211,6 +212,7 @@ type ConfigInfo struct {
NoUpdateModTime bool
DataRateUnit string
BackupDir string
Suffix string
}
// Find the config directory
@@ -263,6 +265,7 @@ func LoadConfig() {
Config.NoTraverse = *noTraverse
Config.NoUpdateModTime = *noUpdateModTime
Config.BackupDir = *backupDir
Config.Suffix = *suffix
ConfigPath = *configFile
@@ -286,6 +289,10 @@ func LoadConfig() {
log.Fatalf(`Can't use --size-only and --ignore-size together.`)
}
if Config.Suffix != "" && Config.BackupDir == "" {
log.Fatalf(`Can only use --suffix with --backup-dir.`)
}
// Load configuration file.
var err error
configData, err = loadConfigFile()