Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b0064e6405 | ||
|
|
3eda36f6da | ||
|
|
a628bef9c2 | ||
|
|
4990535d1b |
No files matched your search
@@ -125,9 +125,9 @@ e/n/d/q> q
|
||||
This can now be used like this
|
||||
|
||||
```
|
||||
rclone lsd remote:// - see all buckets/containers
|
||||
rclone ls remote:// - list a bucket
|
||||
rclone sync /home/local/directory remote://bucket
|
||||
rclone lsd remote: - see all buckets/containers
|
||||
rclone ls remote: - list a bucket
|
||||
rclone sync /home/local/directory remote:bucket
|
||||
```
|
||||
|
||||
See the next section for more details.
|
||||
@@ -146,13 +146,13 @@ See below for how to specify the source and destination paths.
|
||||
Subcommands
|
||||
-----------
|
||||
|
||||
rclone copy source://path dest://path
|
||||
rclone copy source:path dest:path
|
||||
|
||||
Copy the source to the destination. Doesn't transfer
|
||||
unchanged files, testing first by modification time then by
|
||||
MD5SUM. Doesn't delete files from the destination.
|
||||
|
||||
rclone sync source://path dest://path
|
||||
rclone sync source:path dest:path
|
||||
|
||||
Sync the source to the destination. Doesn't transfer
|
||||
unchanged files, testing first by modification time then by
|
||||
@@ -160,28 +160,28 @@ MD5SUM. Deletes any files that exist in source that don't
|
||||
exist in destination. Since this can cause data loss, test
|
||||
first with the -dry-run flag.
|
||||
|
||||
rclone ls [remote://path]
|
||||
rclone ls [remote:path]
|
||||
|
||||
List all the objects in the the path.
|
||||
|
||||
rclone lsd [remote://path]
|
||||
rclone lsd [remote:path]
|
||||
|
||||
List all directoryes/objects/buckets in the the path.
|
||||
|
||||
rclone mkdir remote://path
|
||||
rclone mkdir remote:path
|
||||
|
||||
Make the path if it doesn't already exist
|
||||
|
||||
rclone rmdir remote://path
|
||||
rclone rmdir remote:path
|
||||
|
||||
Remove the path. Note that you can't remove a path with
|
||||
objects in it, use purge for that.
|
||||
|
||||
rclone purge remote://path
|
||||
rclone purge remote:path
|
||||
|
||||
Remove the path and all of its contents.
|
||||
|
||||
rclone check source://path dest://path
|
||||
rclone check source:path dest:path
|
||||
|
||||
Checks the files in the source and destination match. It
|
||||
compares sizes and MD5SUMs and prints a report of files which
|
||||
@@ -212,12 +212,12 @@ Will sync source to destination
|
||||
Swift / Rackspace cloudfiles / Memset Memstore
|
||||
----------------------------------------------
|
||||
|
||||
Paths are specified as remote://container (or remote:// for the `lsd`
|
||||
Paths are specified as remote:container (or remote: for the `lsd`
|
||||
command.)
|
||||
|
||||
So to copy a local directory to a swift container called backup:
|
||||
|
||||
rclone sync /home/source swift://backup
|
||||
rclone sync /home/source swift:backup
|
||||
|
||||
The modified time is stored as metadata on the object as
|
||||
`X-Object-Meta-Mtime` as floating point since the epoch.
|
||||
@@ -229,11 +229,11 @@ os.Stat) for an object.
|
||||
Amazon S3
|
||||
---------
|
||||
|
||||
Paths are specified as remote://bucket
|
||||
Paths are specified as remote:bucket
|
||||
|
||||
So to copy a local directory to a s3 container called backup
|
||||
|
||||
rclone sync /home/source s3://backup
|
||||
rclone sync /home/source s3:backup
|
||||
|
||||
The modified time is stored as metadata on the object as
|
||||
`X-Amz-Meta-Mtime` as floating point since the epoch.
|
||||
@@ -241,7 +241,7 @@ The modified time is stored as metadata on the object as
|
||||
Google drive
|
||||
------------
|
||||
|
||||
Paths are specified as drive://path Drive paths may be as deep as required.
|
||||
Paths are specified as drive:path Drive paths may be as deep as required.
|
||||
|
||||
The initial setup for drive involves getting a token from Google drive
|
||||
which you need to do in your browser. The `rclone config` walks you
|
||||
@@ -286,12 +286,12 @@ y/e/d> y
|
||||
|
||||
You can then use it like this
|
||||
|
||||
rclone lsd drv://
|
||||
rclone ls drv://
|
||||
rclone lsd drv:
|
||||
rclone ls drv:
|
||||
|
||||
To copy a local directory to a drive directory called backup
|
||||
|
||||
rclone copy /home/source drv://backup
|
||||
rclone copy /home/source drv:backup
|
||||
|
||||
Google drive stores modification times accurate to 1 ms.
|
||||
|
||||
|
||||
+5
-7
@@ -10,14 +10,12 @@ gox -output "build/{{.OS}}/{{.Arch}}/{{.Dir}}"
|
||||
cat <<'#EOF' > build/README.txt
|
||||
This directory contains builds of the rclone program.
|
||||
|
||||
Rclone a program designed to stress test your disks and find
|
||||
failures in them.
|
||||
Rclone is a program to transfer files to and from cloud storage
|
||||
systems such as Google Drive, Amazon S3 and Swift (Rackspace
|
||||
Cloudfiles).
|
||||
|
||||
Use it to soak test your new disks / memory cards / USB sticks before
|
||||
trusting your valuable data to it.
|
||||
|
||||
See the project website here: https://github.com/ncw/rclone for
|
||||
more details.
|
||||
See the project website here: https://github.com/ncw/rclone for more
|
||||
details.
|
||||
|
||||
The files in this directory are organised by OS and processor type
|
||||
|
||||
|
||||
+2
-2
@@ -17,7 +17,6 @@ package drive
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
@@ -31,6 +30,7 @@ import (
|
||||
"code.google.com/p/goauth2/oauth"
|
||||
"code.google.com/p/google-api-go-client/drive/v2"
|
||||
"github.com/ncw/rclone/fs"
|
||||
"github.com/ogier/pflag"
|
||||
)
|
||||
|
||||
// Constants
|
||||
@@ -43,7 +43,7 @@ const (
|
||||
// Globals
|
||||
var (
|
||||
// Flags
|
||||
driveFullList = flag.Bool("drive-full-list", true, "Use a full listing for directory list. More data but usually quicker.")
|
||||
driveFullList = pflag.BoolP("drive-full-list", "", true, "Use a full listing for directory list. More data but usually quicker.")
|
||||
)
|
||||
|
||||
// Register with Fs
|
||||
|
||||
+7
-7
@@ -3,7 +3,6 @@ package fs
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
@@ -15,6 +14,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/Unknwon/goconfig"
|
||||
"github.com/ogier/pflag"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -32,12 +32,12 @@ var (
|
||||
// Global config
|
||||
Config = &ConfigInfo{}
|
||||
// Flags
|
||||
verbose = flag.Bool("verbose", false, "Print lots more stuff")
|
||||
quiet = flag.Bool("quiet", false, "Print as little stuff as possible")
|
||||
modifyWindow = flag.Duration("modify-window", time.Nanosecond, "Max time diff to be considered the same")
|
||||
checkers = flag.Int("checkers", 8, "Number of checkers to run in parallel.")
|
||||
transfers = flag.Int("transfers", 4, "Number of file transfers to run in parallel.")
|
||||
configFile = flag.String("config", ConfigPath, "Config file.")
|
||||
verbose = pflag.BoolP("verbose", "v", false, "Print lots more stuff")
|
||||
quiet = pflag.BoolP("quiet", "q", false, "Print as little stuff as possible")
|
||||
modifyWindow = pflag.DurationP("modify-window", "", time.Nanosecond, "Max time diff to be considered the same")
|
||||
checkers = pflag.IntP("checkers", "", 8, "Number of checkers to run in parallel.")
|
||||
transfers = pflag.IntP("transfers", "", 4, "Number of file transfers to run in parallel.")
|
||||
configFile = pflag.StringP("config", "", ConfigPath, "Config file.")
|
||||
)
|
||||
|
||||
// Filesystem config options
|
||||
|
||||
@@ -149,7 +149,7 @@ type Dir struct {
|
||||
type DirChan chan *Dir
|
||||
|
||||
// Pattern to match a url
|
||||
var matcher = regexp.MustCompile(`^([\w_-]+)://(.*)$`)
|
||||
var matcher = regexp.MustCompile(`^([\w_-]+):(.*)$`)
|
||||
|
||||
// Finds a FsInfo object for the name passed in
|
||||
//
|
||||
@@ -211,6 +211,24 @@ func checkClose(c io.Closer, err *error) {
|
||||
}
|
||||
}
|
||||
|
||||
// Work out modify window for fses passed in - sets Config.ModifyWindow
|
||||
//
|
||||
// This is the largest modify window of all the fses in use, and the
|
||||
// user configured value
|
||||
func CalculateModifyWindow(fs ...Fs) {
|
||||
for _, f := range fs {
|
||||
if f != nil {
|
||||
precision := f.Precision()
|
||||
if precision > Config.ModifyWindow {
|
||||
Config.ModifyWindow = precision
|
||||
}
|
||||
}
|
||||
}
|
||||
if Config.Verbose {
|
||||
log.Printf("Modify window is %s\n", Config.ModifyWindow)
|
||||
}
|
||||
}
|
||||
|
||||
// Check the two files to see if the MD5sums are the same
|
||||
//
|
||||
// May return an error which will already have been logged
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
@@ -14,6 +13,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/ogier/pflag"
|
||||
|
||||
"github.com/ncw/rclone/fs"
|
||||
// Active file systems
|
||||
_ "github.com/ncw/rclone/drive"
|
||||
@@ -25,9 +26,9 @@ import (
|
||||
// Globals
|
||||
var (
|
||||
// Flags
|
||||
cpuprofile = flag.String("cpuprofile", "", "Write cpu profile to file")
|
||||
dry_run = flag.Bool("dry-run", false, "Do a trial run with no permanent changes")
|
||||
statsInterval = flag.Duration("stats", time.Minute*1, "Interval to print stats")
|
||||
cpuprofile = pflag.StringP("cpuprofile", "", "", "Write cpu profile to file")
|
||||
dry_run = pflag.BoolP("dry-run", "n", false, "Do a trial run with no permanent changes")
|
||||
statsInterval = pflag.DurationP("stats", "", time.Minute*1, "Interval to print stats")
|
||||
)
|
||||
|
||||
// A pair of fs.Objects
|
||||
@@ -131,7 +132,7 @@ func DeleteFiles(to_be_deleted fs.ObjectsChan) {
|
||||
defer wg.Done()
|
||||
for dst := range to_be_deleted {
|
||||
if *dry_run {
|
||||
fs.Debug(dst, "Not deleting as -dry-run")
|
||||
fs.Debug(dst, "Not deleting as --dry-run")
|
||||
} else {
|
||||
fs.Stats.Checking(dst)
|
||||
err := dst.Remove()
|
||||
@@ -339,7 +340,7 @@ func mkdir(fdst, fsrc fs.Fs) {
|
||||
// Removes a container but not if not empty
|
||||
func rmdir(fdst, fsrc fs.Fs) {
|
||||
if *dry_run {
|
||||
log.Printf("Not deleting %s as -dry-run", fdst)
|
||||
log.Printf("Not deleting %s as --dry-run", fdst)
|
||||
} else {
|
||||
err := fdst.Rmdir()
|
||||
if err != nil {
|
||||
@@ -414,7 +415,7 @@ var Commands = []Command{
|
||||
unchanged files, testing first by modification time then by
|
||||
MD5SUM. Deletes any files that exist in source that don't
|
||||
exist in destination. Since this can cause data loss, test
|
||||
first with the -dry-run flag.`,
|
||||
first with the --dry-run flag.`,
|
||||
Run: Sync,
|
||||
MinArgs: 2,
|
||||
MaxArgs: 2,
|
||||
@@ -507,7 +508,7 @@ Subcommands:
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "Options:\n")
|
||||
flag.PrintDefaults()
|
||||
pflag.PrintDefaults()
|
||||
fmt.Fprintf(os.Stderr, `
|
||||
It is only necessary to use a unique prefix of the subcommand, eg 'up' for 'upload'.
|
||||
`)
|
||||
@@ -520,10 +521,10 @@ func fatal(message string, args ...interface{}) {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Usage = syntaxError
|
||||
flag.Parse()
|
||||
args := flag.Args()
|
||||
// Parse the command line flags
|
||||
func ParseFlags() {
|
||||
pflag.Usage = syntaxError
|
||||
pflag.Parse()
|
||||
runtime.GOMAXPROCS(runtime.NumCPU())
|
||||
fs.LoadConfig()
|
||||
|
||||
@@ -537,7 +538,11 @@ func main() {
|
||||
pprof.StartCPUProfile(f)
|
||||
defer pprof.StopCPUProfile()
|
||||
}
|
||||
}
|
||||
|
||||
// Parse the command from the command line
|
||||
func ParseCommand() (*Command, []string) {
|
||||
args := pflag.Args()
|
||||
if len(args) < 1 {
|
||||
fatal("No command supplied\n")
|
||||
}
|
||||
@@ -546,80 +551,77 @@ func main() {
|
||||
args = args[1:]
|
||||
|
||||
// Find the command doing a prefix match
|
||||
var found *Command
|
||||
var command *Command
|
||||
for i := range Commands {
|
||||
command := &Commands[i]
|
||||
trialCommand := &Commands[i]
|
||||
// exact command name found - use that
|
||||
if command.Name == cmd {
|
||||
found = command
|
||||
if trialCommand.Name == cmd {
|
||||
command = trialCommand
|
||||
break
|
||||
} else if strings.HasPrefix(command.Name, cmd) {
|
||||
if found != nil {
|
||||
} else if strings.HasPrefix(trialCommand.Name, cmd) {
|
||||
if command != nil {
|
||||
fs.Stats.Error()
|
||||
log.Fatalf("Not unique - matches multiple commands %q", cmd)
|
||||
}
|
||||
found = command
|
||||
command = trialCommand
|
||||
}
|
||||
}
|
||||
if found == nil {
|
||||
if command == nil {
|
||||
fs.Stats.Error()
|
||||
log.Fatalf("Unknown command %q", cmd)
|
||||
}
|
||||
found.checkArgs(args)
|
||||
if command.Run == nil {
|
||||
syntaxError()
|
||||
}
|
||||
command.checkArgs(args)
|
||||
return command, args
|
||||
}
|
||||
|
||||
// Create a Fs from a name
|
||||
func NewFs(remote string) fs.Fs {
|
||||
f, err := fs.NewFs(remote)
|
||||
if err != nil {
|
||||
fs.Stats.Error()
|
||||
log.Fatalf("Failed to create file system for %q: %v", remote, err)
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// Print the stats every statsInterval
|
||||
func StartStats() {
|
||||
go func() {
|
||||
ch := time.Tick(*statsInterval)
|
||||
for {
|
||||
<-ch
|
||||
fs.Stats.Log()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func main() {
|
||||
ParseFlags()
|
||||
command, args := ParseCommand()
|
||||
|
||||
// Make source and destination fs
|
||||
var fdst, fsrc fs.Fs
|
||||
var err error
|
||||
if len(args) >= 1 {
|
||||
fdst, err = fs.NewFs(args[0])
|
||||
if err != nil {
|
||||
fs.Stats.Error()
|
||||
log.Fatalf("Failed to create file system for %q: %v", args[0], err)
|
||||
}
|
||||
fdst = NewFs(args[0])
|
||||
}
|
||||
if len(args) >= 2 {
|
||||
fsrc, err = fs.NewFs(args[1])
|
||||
if err != nil {
|
||||
fs.Stats.Error()
|
||||
log.Fatalf("Failed to create destination file system for %q: %v", args[1], err)
|
||||
}
|
||||
fsrc, fdst = fdst, fsrc
|
||||
fsrc = fdst
|
||||
fdst = NewFs(args[1])
|
||||
}
|
||||
|
||||
// Work out modify window
|
||||
if fsrc != nil {
|
||||
precision := fsrc.Precision()
|
||||
log.Printf("Source precision %s\n", precision)
|
||||
if precision > fs.Config.ModifyWindow {
|
||||
fs.Config.ModifyWindow = precision
|
||||
}
|
||||
}
|
||||
if fdst != nil {
|
||||
precision := fdst.Precision()
|
||||
log.Printf("Destination precision %s\n", precision)
|
||||
if precision > fs.Config.ModifyWindow {
|
||||
fs.Config.ModifyWindow = precision
|
||||
}
|
||||
}
|
||||
if fs.Config.Verbose {
|
||||
log.Printf("Modify window is %s\n", fs.Config.ModifyWindow)
|
||||
}
|
||||
fs.CalculateModifyWindow(fdst, fsrc)
|
||||
|
||||
// Print the stats every statsInterval
|
||||
if !found.NoStats {
|
||||
go func() {
|
||||
ch := time.Tick(*statsInterval)
|
||||
for {
|
||||
<-ch
|
||||
fs.Stats.Log()
|
||||
}
|
||||
}()
|
||||
if !command.NoStats {
|
||||
StartStats()
|
||||
}
|
||||
|
||||
// Run the actual command
|
||||
if found.Run != nil {
|
||||
found.Run(fdst, fsrc)
|
||||
if !found.NoStats {
|
||||
if command.Run != nil {
|
||||
command.Run(fdst, fsrc)
|
||||
if !command.NoStats {
|
||||
fmt.Println(fs.Stats)
|
||||
}
|
||||
if fs.Config.Verbose {
|
||||
@@ -630,7 +632,6 @@ func main() {
|
||||
}
|
||||
os.Exit(0)
|
||||
} else {
|
||||
syntaxError()
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user