LinuxCommandLibrary

nextcloudcmd

Synchronize files with a Nextcloud server

SYNOPSIS

nextcloudcmd [OPTIONS]

Note: is the path to the local directory or file to synchronize.
Note: is the URL of the Nextcloud server and the target path within it, e.g., https://your-nextcloud.com/remote.php/webdav/path/to/folder.

PARAMETERS

-u, --user
    Specifies the username for authentication with the Nextcloud server.

-p, --password
    Provides the password for the specified user. (Warning: Using this directly in scripts is insecure. Consider environment variables or config files.)

-n, --dry-run
    Performs a dry run, simulating the synchronization process without making actual changes. Useful for testing.

-h, --help
    Displays the help message and exits.

-v, --version
    Shows the version information of the nextcloudcmd client.

-s, --skip-existing
    Skips synchronization for files that already exist on the server.

-f, --force
    Forces overwriting of existing files on the server with local versions.

-d, --delete
    Deletes local files that have been removed on the Nextcloud server.

-q, --quiet
    Suppresses most output messages during synchronization.

-c, --config
    Specifies an alternative configuration file to use.

--exclude
    Excludes files or directories matching the given pattern from synchronization. Can be used multiple times.

--include
    Includes files or directories matching the given pattern, overriding --exclude. Can be used multiple times.

--non-interactive
    Disables interactive prompts, making the command suitable for automated scripts.

--trust
    Trusts all SSL certificates without validation. (Warning: Highly insecure and should be avoided in production environments.)

--exclude-file
    Reads exclusion patterns from the specified file, one pattern per line.

--cacert
    Specifies the path to a custom CA certificate bundle for SSL/TLS validation.

DESCRIPTION

nextcloudcmd is a robust command-line interface tool designed for synchronizing local files and directories with a Nextcloud server.

As an integral component of the Nextcloud Desktop Client suite, it provides a powerful, non-graphical alternative for users and administrators to manage their Nextcloud data. This utility is especially valuable for automation tasks, such as scripting routine backups, deploying files to multiple servers, or performing synchronization on environments without a graphical user interface, like headless servers or CI/CD pipelines.

It offers comprehensive control over the synchronization process, supporting diverse authentication methods and featuring options for simulating operations (dry-runs), enforcing file overwrites, specifying inclusion and exclusion patterns for precise control over what gets synced, and enabling non-interactive execution for automated workflows. Its flexibility makes it a key tool for integrating Nextcloud into server-side operations and custom scripts.

CAVEATS

Security Warning: Providing passwords directly via the -p option is insecure. Consider using environment variables, configuration files, or interactive prompts where possible.

SSL/TLS Validation: The --trust option disables crucial security checks and should never be used in production environments. Always prefer proper SSL certificate validation using --cacert or system trust stores.

Performance: For very large datasets, the command-line client might be less performant or feature-rich compared to the graphical desktop client which maintains a local database of synced files.

ENVIRONMENT VARIABLES

The command can utilize environment variables for sensitive information like passwords, e.g., NEXTCLOUD_PASSWORD, to avoid exposing them in command history or process listings.

EXIT CODES

nextcloudcmd typically returns an exit code of 0 on successful synchronization and a non-zero value for errors, which is useful for scripting and error handling.

WEBDAV URL STRUCTURE

The typically follows the format: https://your-nextcloud.com/remote.php/webdav/ followed by the desired path within your Nextcloud instance. Ensure the path is correct for successful synchronization.

HISTORY

nextcloudcmd is an integral part of the Nextcloud Desktop Client, which originated from the ownCloud Desktop Client. As ownCloud forked into Nextcloud, the client application and its command-line component evolved alongside the Nextcloud server, providing consistent and reliable file synchronization capabilities for users and administrators. Its development focuses on extending the desktop client's features to non-GUI environments, ensuring broad utility across different computing setups.

SEE ALSO

rsync(1), curl(1), webdavfs(8)

Copied to clipboard