Skip to content

Commit

Permalink
adding QNAP instructions and compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
artooro committed Feb 7, 2017
1 parent 11ebcb6 commit 5715317
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 7 deletions.
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,30 @@ on a really flexible search query system.
`drivebackup --data ~/backup`

See https://developers.google.com/drive/v3/web/search-parameters#examples
for further examples of using --filter
for further examples of using --filter

## Installation on a QNAP

Copy the drivebackup binary to your QNAP using SSH.

`scp drivebackup [email protected]:`

_Replace [email protected] with the actual username and IP address_

Run manually once to authenticate.

`./drivebackup --configure`

Create cron job

`echo '30 3 * * 0 /root/drivebackup --data /share/MD0_DATA/mybackupshare --filter "'1B8dgVVPsv2wOeE2pX19kNU91bTg' in parents"' >> /etc/config/crontab`

Restart the cron daemon

`crontab /etc/config/crontab && /etc/init.d/crond.sh restart`

__Be sure to change the command to include your own options__

The above example will run at 03:30 every Sunday and backup everything from the
Google Drive folder with an ID of 1B8dgVVPsv2wOeE2pX19kNU91bTg to the QNAP share
called mybackupshare that is stored on the MD0_DATA volume.
14 changes: 8 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ type Config struct {
var (
directory = flag.String("data", "./", "Path to directory where you want the backup saved.")
search = flag.String("filter", "", "A Drive search query used to filter what files you want" +
"to backup.")
" to backup.")
configure = flag.Bool("configure", false, "Configure authentication tokens.")
)

var (
Expand Down Expand Up @@ -311,10 +312,7 @@ func main() {
conf.Storage = *directory
conf.Filter = *search

b, err := ioutil.ReadFile("client_id.json")
if err != nil {
log.Fatalf("Unable to read client id file: %v", err)
}
b := []byte("{\"installed\":{\"client_id\":\"509615771323-pntgak8thbl9ia0sd3gtb0t31utkkn6m.apps.googleusercontent.com\",\"project_id\":\"drive-backup-156821\",\"auth_uri\":\"https://accounts.google.com/o/oauth2/auth\",\"token_uri\":\"https://accounts.google.com/o/oauth2/token\",\"auth_provider_x509_cert_url\":\"https://www.googleapis.com/oauth2/v1/certs\",\"client_secret\":\"LvoP9X8RAZC3J6adRN3o-Xvb\",\"redirect_uris\":[\"urn:ietf:wg:oauth:2.0:oob\",\"http://localhost\"]}}")

// Read-only scope is critical to prevent any changes/mistakes to the production Drive
// We don't care about restore. User would manually restore files from the backup
Expand All @@ -330,5 +328,9 @@ func main() {
log.Fatalf("Unable to get Drive client: %v", err)
}

run_backup(*srv)
if !*configure {
run_backup(*srv)
} else {
fmt.Println("Configuration complete!")
}
}

0 comments on commit 5715317

Please sign in to comment.