1
0
Fork 0
mirror of https://github.com/Luzifer/duplicity-backup.git synced 2024-11-09 15:40:06 +00:00

Added "list-changed-files" command

This commit is contained in:
Knut Ahlers 2016-06-26 01:33:28 +02:00
parent 8f9cfaa326
commit 45d4589253
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
4 changed files with 30 additions and 16 deletions

View file

@ -68,7 +68,7 @@ func (fi bindataFileInfo) Sys() interface{} {
return nil return nil
} }
var _helpTxt = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x94\x31\x73\xdb\x3c\x0c\x86\x77\xfd\x0a\x8c\xdf\x37\x28\xde\xb3\xf5\xe2\xf3\xd4\xa1\xd7\x5e\xaf\x83\xcf\x03\x4c\x41\x12\x2f\x34\xa9\x03\xc1\xa4\xf6\xd0\xdf\x5e\x90\x54\x14\xc5\x8e\xb7\x62\x33\x09\x3c\x7c\xf5\x02\xf0\x2f\xc6\x69\x22\x06\xe4\x90\x7c\x07\x5d\x9a\x9c\x35\x56\xce\x20\x01\x0c\x13\x0a\xc1\x11\xcd\x73\x9a\xe0\xd5\xca\x08\x8e\x62\x84\x11\x2f\x17\x47\x4d\xf3\x33\xe2\x40\x8f\x0d\xbc\x57\xb5\x73\xee\xde\x84\xd3\x09\x7d\x77\x68\x9a\x2f\x2f\x68\x1d\x1e\x1d\xc1\x53\x3d\x8b\xb9\x62\xce\xdb\x80\xf5\x86\xe1\x3a\x9e\x3e\x3c\x8c\xc6\x04\xee\xac\x1f\xb2\x26\x19\x97\x73\x4e\xaa\x46\x59\x7d\x72\xee\x06\xb1\xc4\x2e\xb0\xa1\x58\xea\xca\xf7\xd8\xe0\x21\xf4\x80\xb5\xac\xa2\x14\x62\x1c\xa1\x57\xe8\xe7\xb1\x25\x47\x2a\x28\x43\xe8\xb7\x30\x7a\x0a\x29\xae\xcc\xea\x6d\x95\xe2\x6c\x94\xd6\x24\x66\xf2\xd2\x96\xc3\x35\xe5\xab\xde\x56\x25\xf5\xca\x04\x2f\x68\x3d\x75\xea\xc2\xea\xc3\x94\xc3\x14\x25\x30\xc1\x3e\x27\xc2\x84\x32\x1e\x60\x2f\xc8\x03\xc9\x01\xe0\x7b\xbd\x8d\x10\xd5\x14\x57\x69\x6a\x65\x67\xb9\x38\x54\xd2\xf2\x2f\x32\x9a\x76\x5e\xe3\x16\xc4\x3a\x16\x1c\xbd\x10\x9f\x65\x7c\x73\xfa\x96\x13\x05\x25\xc5\x7b\x4e\xff\x48\xda\x5f\xb6\x97\xea\xd3\x9c\xab\x56\xaf\x5b\x46\x53\x88\x76\xa6\xe9\x6b\xb6\x3f\xdf\xa3\xe9\xb4\x4c\x98\x55\xcd\xa5\xd9\x2c\x75\x35\x02\x0e\xea\x59\x14\x70\xc1\xa0\x9b\x9d\x6f\x76\x0e\x87\x32\x58\x6d\xab\x89\xbd\x1d\xda\xd9\x94\xb6\xff\x08\xcd\x77\x89\xeb\x18\xf4\x41\x0d\x1b\xed\xba\x91\xaf\x75\x1d\x9a\xfb\xf3\x54\xe3\xbf\x2d\xf5\x98\x9c\x3c\xc2\x9f\xcd\x43\x7d\x71\x73\xbd\x05\x0f\x67\x3c\xb9\xff\x8b\x26\xd5\xfa\xbc\x28\xba\x1a\xd6\x5d\x3e\x56\xbf\xc7\xe0\xba\xe2\x55\x4e\x7e\xd7\x36\x2b\xd2\xb9\x23\x93\xb2\xec\x7f\xa3\x2d\x3f\x52\xb5\x75\x74\x4c\x43\xd6\xd5\xdd\xa2\xbe\xb1\xf5\xb2\xb2\x67\x5e\xeb\x98\xf5\x86\x24\x53\x92\x8a\x60\x69\x39\xf9\x0c\xf1\xd7\x88\x6d\xd0\x5d\x13\x1d\xb1\x92\x91\xff\x44\xb4\x10\xcc\x88\x7e\x28\x2b\xd3\xb6\x3a\x07\x31\xb7\xe3\xb3\x28\x02\xe6\xed\xad\x6b\x05\x13\x87\x81\xf1\x04\x6f\x65\xaa\x47\xcd\xb1\x12\x9b\xbf\x01\x00\x00\xff\xff\xde\xa9\xe5\x3d\xcc\x04\x00\x00") var _helpTxt = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xac\x94\xb1\x8e\xdb\x30\x0c\x86\x77\x3f\x05\xc7\x76\xf0\xdd\x7e\x5b\x71\x41\xa6\x0e\x45\x8b\xa2\x43\x90\x81\x91\x69\x5b\x38\x45\x32\x28\xea\xae\xc9\xd0\x67\x2f\x65\x29\x89\x2f\xb9\x00\x1d\xca\x2d\x12\xf9\xe9\xcf\x4f\xd2\xbf\x18\xa7\x89\x18\x90\x43\xf2\x1d\x74\x69\x72\xd6\x58\x39\x80\x04\x30\x4c\x28\x04\x3b\x34\x2f\x69\x82\x37\x2b\x23\x38\x8a\x11\x46\x3c\x1e\x1d\x35\xcd\xcf\x88\x03\x3d\x35\x70\xa9\x6a\x6b\xee\xc6\x84\xfd\x1e\x7d\xb7\x6d\x9a\x2f\xaf\x68\x1d\xee\x1c\xc1\x73\x39\x8b\xb9\xa2\xe6\x3d\x82\xf5\x86\xe1\x3a\x9e\xdf\x3d\x8c\xc6\x04\xee\xac\x1f\xb2\x26\x19\xcf\xe7\x9c\x54\x8d\xb2\xfa\xe4\xdc\x0d\xe2\x1c\xeb\xc0\x86\xe2\x5c\x37\xff\x1f\x1b\x3c\x84\x1e\xb0\x94\x15\x94\x42\x8c\x23\xf4\x0a\xfd\x38\x56\xe4\x48\x05\x65\x08\xfd\x16\x46\x4f\x21\xc5\x85\x59\xbd\x2d\x52\x9c\x8d\xd2\x9a\x11\xfd\x40\x5d\x3b\x1f\x2e\x29\x5f\xf5\xb6\x28\x29\x57\x35\x11\xa2\x9a\x40\xe0\x30\xca\x45\x4f\x21\x25\x66\xf2\xf2\x0f\xa4\xe0\x05\xad\x57\x96\xf5\x0b\x8b\x94\xc3\x14\x25\x30\xc1\x26\x27\xc2\x84\x32\x6e\x61\x23\xc8\x03\xc9\x16\xe0\x7b\xb9\x8d\x59\xc2\xe0\x0a\x4d\x9b\xd2\x59\x9e\xbd\x9e\xd3\xf2\x2f\x32\x9a\x76\x58\xe2\xce\x88\x65\x9c\x71\xf4\x4a\x7c\x90\xf1\xd4\xb3\x5b\x4e\x14\x94\x14\xef\xf5\xec\x47\xd2\x49\x61\x7b\x2c\x8e\xd7\x5c\x6d\xda\xb2\xf9\x34\x85\x68\x2b\x4d\x5f\xb3\xfd\xe1\x1e\x4d\xe7\x6e\xc2\xac\xaa\x96\x66\xb3\xd4\xd5\x08\x38\xa8\x67\x6a\xba\x0b\x06\x5d\xed\x61\xb3\x76\x38\xcc\x23\xda\xb6\x9a\xd8\xdb\xa1\xad\xa6\xb4\xfd\x7b\x68\xbe\x4b\x5c\x06\xaa\x0f\x6a\xd8\x68\x97\x23\xf1\x56\x16\xab\xb9\xa7\xea\x14\x9f\x56\xd4\x63\x72\xf2\x04\x7f\x1e\x1f\xca\x8b\x8f\xd7\xfb\xf4\x70\xc0\xbd\xfb\x3c\x6b\x52\xad\x2f\x67\x45\x57\x63\xbf\xce\xc7\xea\xf7\x18\x5c\x37\x7b\x95\x93\x2f\xda\xaa\x22\x9d\x60\x32\x29\xcb\xfe\x3f\xda\xf2\x23\x45\x5b\x47\xbb\x34\x64\x5d\xdd\x2d\xea\x1b\x5b\x2f\x0b\x7b\xea\x07\x22\x66\xbd\x21\xc9\x94\xa4\x20\x58\x5a\x4e\x3e\x43\xfc\x35\x62\x15\x74\x6b\x45\x47\x6c\xce\xc8\x9f\x23\x2d\xac\x4b\x14\xe7\x6a\x9d\x83\x98\xdb\xf1\x51\xcc\x02\xea\x77\xa0\xac\x15\x4c\x1c\x06\xc6\x3d\x9c\xca\x54\x8f\x9a\x63\x25\x36\x7f\x03\x00\x00\xff\xff\x42\x8c\xc7\xe4\x16\x05\x00\x00")
func helpTxtBytes() ([]byte, error) { func helpTxtBytes() ([]byte, error) {
return bindataRead( return bindataRead(
@ -83,7 +83,7 @@ func helpTxt() (*asset, error) {
return nil, err return nil, err
} }
info := bindataFileInfo{name: "help.txt", size: 1228, mode: os.FileMode(420), modTime: time.Unix(1464030604, 0)} info := bindataFileInfo{name: "help.txt", size: 1302, mode: os.FileMode(420), modTime: time.Unix(1466894900, 0)}
a := &asset{bytes: bytes, info: info} a := &asset{bytes: bytes, info: info}
return a, nil return a, nil
} }

View file

@ -7,6 +7,7 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"os" "os"
"regexp"
"strconv" "strconv"
"text/template" "text/template"
@ -15,15 +16,16 @@ import (
) )
const ( const (
commandBackup = "backup" commandBackup = "backup"
commandFullBackup = "full" commandFullBackup = "full"
commandIncrBackup = "incr" commandIncrBackup = "incr"
commandCleanup = "cleanup" commandCleanup = "cleanup"
commandList = "list-current-files" commandList = "list-current-files"
commandRestore = "restore" commandRestore = "restore"
commandStatus = "status" commandStatus = "status"
commandVerify = "verify" commandVerify = "verify"
commandRemove = "__remove_old" commandRemove = "__remove_old"
commandListChangedFiles = "list-changed-files"
) )
var ( var (
@ -170,7 +172,7 @@ func loadConfigFile(in io.Reader) (*configFile, error) {
return res, res.validate() return res, res.validate()
} }
func (c *configFile) GenerateCommand(argv []string, time string) (commandLine []string, env []string, err error) { func (c *configFile) GenerateCommand(argv []string, time string) (commandLine []string, env []string, logfilter *regexp.Regexp, err error) {
var ( var (
tmpEnv []string tmpEnv []string
option, root, dest string option, root, dest string
@ -184,6 +186,13 @@ func (c *configFile) GenerateCommand(argv []string, time string) (commandLine []
root = c.RootPath root = c.RootPath
dest = c.Destination dest = c.Destination
commandLine, env, err = c.generateFullCommand(option, time, root, dest, addTime, "") commandLine, env, err = c.generateFullCommand(option, time, root, dest, addTime, "")
case commandListChangedFiles:
option = ""
root = c.RootPath
dest = c.Destination
commandLine, env, err = c.generateFullCommand(option, time, root, dest, addTime, "")
commandLine = append([]string{"--dry-run", "--verbosity", "8"}, commandLine...)
logfilter = regexp.MustCompile(`^[ADM] `)
case commandFullBackup: case commandFullBackup:
option = command option = command
root = c.RootPath root = c.RootPath

View file

@ -7,6 +7,7 @@ Available Commands:
backup / incr Create backup according to the backup rules backup / incr Create backup according to the backup rules
full Forces the creation of a full backup full Forces the creation of a full backup
cleanup Delete the extraneous duplicity files cleanup Delete the extraneous duplicity files
list-changed-files Lists the files changed since last backup
list-current-files Lists the files contained in the backup list-current-files Lists the files contained in the backup
restore [file path] [target] Restores single file / dir to target directory restore [file path] [target] Restores single file / dir to target directory
restore [target] Restores everything to target directory restore [target] Restores everything to target directory

12
main.go
View file

@ -6,6 +6,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path" "path"
"regexp"
"strings" "strings"
"time" "time"
@ -142,8 +143,9 @@ func execute(config *configFile, argv []string) error {
var ( var (
err error err error
commandLine, tmpEnv []string commandLine, tmpEnv []string
logFilter *regexp.Regexp
) )
commandLine, tmpEnv, err = config.GenerateCommand(argv, cfg.RestoreTime) commandLine, tmpEnv, logFilter, err = config.GenerateCommand(argv, cfg.RestoreTime)
if err != nil { if err != nil {
logf("[ERR] %s", err) logf("[ERR] %s", err)
return err return err
@ -166,11 +168,13 @@ func execute(config *configFile, argv []string) error {
} }
msgChan := make(chan string, 10) msgChan := make(chan string, 10)
go func(c chan string) { go func(c chan string, logFilter *regexp.Regexp) {
for l := range c { for l := range c {
logf(l) if logFilter == nil || logFilter.MatchString(l) {
logf(l)
}
} }
}(msgChan) }(msgChan, logFilter)
output := newMessageChanWriter(msgChan) output := newMessageChanWriter(msgChan)
cmd := exec.Command(duplicityBinary, commandLine...) cmd := exec.Command(duplicityBinary, commandLine...)