Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

bisync: change exit code from 2 to 7 for critically aborted run

albertony3dec664a19b1
diff --git a/cmd/bisync/cmd.go b/cmd/bisync/cmd.go
index 22a600923..c8b2136c4 100644
--- a/cmd/bisync/cmd.go
+++ b/cmd/bisync/cmd.go
@@ -20,6 +20,7 @@ import (
"github.com/rclone/rclone/fs/config"
"github.com/rclone/rclone/fs/config/flags"
"github.com/rclone/rclone/fs/filter"
+ "github.com/rclone/rclone/fs/fserrors"
"github.com/rclone/rclone/fs/hash"
"github.com/spf13/cobra"
@@ -193,7 +194,7 @@ var commandDefinition = &cobra.Command{
cmd.Run(false, true, command, func() error {
err := Bisync(ctx, fs1, fs2, &opt)
if err == ErrBisyncAborted {
- os.Exit(2)
+ return fserrors.FatalError(err)
}
return err
})
diff --git a/cmd/bisync/operations.go b/cmd/bisync/operations.go
index b457645fa..987a94e66 100644
--- a/cmd/bisync/operations.go
+++ b/cmd/bisync/operations.go
@@ -23,7 +23,7 @@ import (
"github.com/rclone/rclone/lib/terminal"
)
-// ErrBisyncAborted signals that bisync is aborted and forces exit code 2
+// ErrBisyncAborted signals that bisync is aborted and forces non-zero exit code
var ErrBisyncAborted = errors.New("bisync aborted")
// bisyncRun keeps bisync runtime state
diff --git a/docs/content/bisync.md b/docs/content/bisync.md
index 8f0bf4883..94a51fd9e 100644
--- a/docs/content/bisync.md
+++ b/docs/content/bisync.md
@@ -968,12 +968,15 @@ that while concurrent bisync runs are allowed, _be very cautious_
that there is no overlap in the trees being synched between concurrent runs,
lest there be replicated files, deleted files and general mayhem.
-### Return codes
+### Exit codes
`rclone bisync` returns the following codes to calling program:
- `0` on a successful run,
- `1` for a non-critical failing run (a rerun may be successful),
-- `2` for a critically aborted run (requires a `--resync` to recover).
+- `2` on syntax or usage error,
+- `7` for a critically aborted run (requires a `--resync` to recover).
+
+See also the section about [exit codes](/docs/#exit-code) in main docs.
### Graceful Shutdown