Skip to content

Commit

Permalink
Allow to customize where backups are stored. Closes #28.
Browse files Browse the repository at this point in the history
  • Loading branch information
zerok committed Oct 17, 2017
1 parent ffe49ee commit 3d5cb3f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ clock in or out, a new snapshot will be made. By default the backup repository
is stored in `$HOME/.clocked_backups` and its password is saved in
`$HOME/.clocked/backups.passwd`

If you want to keep your backups somewhere else (e.g. inside a Dropbox folder)
you have to do two things:

1. Move `~/.clocked_backups` to its target location.
2. Inside `~/.clocked/config.yml` add the following line:

```
backups_path: /Users/yourname/Dropbox/clocked_backups
```

Replace `/Users/yourname/Dropbox/clocked_backups` with whatever path you
moved the backups to in step 1 🙂

## Command-line arguments

- `--log-file <path/to/file>` specifies a path to a logfile clocked should
Expand Down
3 changes: 2 additions & 1 deletion cmd/clocked/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func main() {
}

bk, err := backup.New(&backup.Options{
SourcePath: storageFolder,
SourcePath: storageFolder,
RepositoryPath: cfg.BackupsPath,
})
if err != nil {
log.WithError(err).Fatal("Failed to configure backup")
Expand Down
10 changes: 2 additions & 8 deletions internal/backup/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,13 @@ func (b *Backup) createEnv() []string {
func (b *Backup) CreateSnapshot() error {
cmd := exec.Command(b.resticPath, "backup", b.sourcePath)
cmd.Env = b.createEnv()
if err := cmd.Run(); err != nil {
return err
}
return nil
return cmd.Run()
}

func (b *Backup) Restore(id string) error {
cmd := exec.Command(b.resticPath, "restore", "--target", filepath.Dir(b.sourcePath), id)
cmd.Env = b.createEnv()
if err := cmd.Run(); err != nil {
return err
}
return nil
return cmd.Run()
}

type ByTime []Snapshot
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

type Config struct {
BackupsPath string `yaml:"backups_path"`
JIRAUsername string `yaml:"jira_username"`
JIRAURL string `yaml:"jira_url"`
JIRAPassword string
Expand Down

0 comments on commit 3d5cb3f

Please sign in to comment.