Skip to content

Storing defaults for global flags in the config file (profiles) #2697

Open

Description

@ncw

Make a global config setting for rclone

In the rclone config file have configuration for "profiles". These are default settings for all the rclone flags.

So the flag "--delete-during" would be stored like this in the config in the default profile.

[:default]
delete_during = true

Rclone would provide the --profile flag to use a different profile and provide rclone config profile to edit the profile with a config profile editor wizard.

Backend flags should be settable in the profile also - basically any flag that rclone has should be settable in the profile (just like it is settable in the environment already).

Extension idea: could inherit from other profiles.

Activity

  1. added this to the v1.45 milestone on Oct 25, 2018
  2. self-assigned this
    on Oct 25, 2018
  3. modified the milestones: v1.45, v1.46 on Nov 24, 2018
  4. modified the milestones: v1.46, v1.47 on Feb 9, 2019
  5. modified the milestones: v1.47, v1.48 on Apr 15, 2019
  6. modified the milestones: v1.48, v1.49 on Jun 19, 2019
  7. modified the milestones: v1.49, v1.50 on Aug 27, 2019
  8. harryqt commented on Oct 25, 2019

    @harryqt
    Contributor

    I would also love to see this. But judging by the milestone shifting I'm guessing it's hard to implement?

  9. ncw commented on Oct 26, 2019

    @ncw
    MemberAuthor

    would also love to see this. But judging by the milestone shifting I'm guessing it's hard to implement?

    So much to do, so little time :-)

    It isn't particularly tricky - fancy helping out?

  10. 41 remaining items

  11. nielash commented on Jan 12, 2024

    @nielash
    Contributor

    @ncw I took a stab at implementing this. It's still a WIP but if you have a moment, it would be very helpful if you could take a peek and let me know if I'm on the right track: nielash@60b9568

    Features:

    • save a profile while running any other command by adding --save-profile NAME
    • use one or more profiles with a command by adding --use-profile NAME1,NAME2,NAME3...
    • --profile-include-args to include the command's args in addition to flags (for example, two long paths that you sync regularly)
    • Support for inheriting settings from multiple nested "parent" profiles
    • Support for setting one "default" profile in the config, for use cases where users can't set --use-profile from command line flags or env vars
    • new dedicated setprofile command
    • new dedicated profiles wizard UI in rclone config profile

    There are a number of (passing!) tests here that show the intended use:
    https://github.com/nielash/rclone/blob/profiles-WIP/fs/config/configprofiles/profiles_test.go

  12. ncw commented on Feb 2, 2024

    @ncw
    MemberAuthor

    @nielash

    I took a stab at implementing this. It's still a WIP but if you have a moment, it would be very helpful if you could take a peek and let me know if I'm on the right track: nielash@60b9568

    Very nice list of features :-) You've done a very thorough job.

    This is going to need lots of docs!

    I did also have the idea that we could introduce global flags to set when using a backend. So when you do

    [myremote]
    type = s3
    whatever = blah
    --inplace = true
    

    This would set the --inplace flag which would be rather like using --profile myremote if you see what I mean.

    So if we could arrange for the profile settings and the flag settings not to clash then we can enable this if we want.

    Looking at the code you are using type = profile to tell the profiles apart from backends which seems sensible.

    • save a profile while running any other command by adding --save-profile NAME

    Very nice feature!

    • use one or more profiles with a command by adding --use-profile NAME1,NAME2,NAME3...

    This should probably just be --profile (eg the aws command).

    • --profile-include-args to include the command's args in addition to flags (for example, two long paths that you sync regularly)

    This should probably default to true - if you put args in the profile then you'd expect to use them.

    • Support for inheriting settings from multiple nested "parent" profiles

    How do you do that - I missed that in the code.

    This could potentially be the mechanism for including a profile in a backend definition rather than including the flags directly.

    • Support for setting one "default" profile in the config, for use cases where users can't set --use-profile from command line flags or env vars
    • new dedicated setprofile command
    • new dedicated profiles wizard UI in rclone config profile

    All good!

    There are a number of (passing!) tests here that show the intended use: https://github.com/nielash/rclone/blob/profiles-WIP/fs/config/configprofiles/profiles_test.go

    Nice!

    I think what this needs next is

    • docs - this needs some really clear docs on how to use profiles, how they work, how they appear in the config file, how to edit them etc. This should be a section in docs.md and what we can do is run that by the users on the forum along with a link to a beta to get some feedback.
    • can you try to break the commit up into smaller chunks for easier review please :-)
    • we probably should have some API to do stuff with profiles, though maybe the existing config api will work

    Very nice work :-)

  13. nielash commented on Feb 3, 2024

    @nielash
    Contributor

    Very helpful feedback -- thank you!

    • Support for inheriting settings from multiple nested "parent" profiles

    How do you do that - I missed that in the code.

    In the config they are saved as a comma-separated list under the parent_profiles key, and then the p.Use method calls p.useParents, which eventually calls p.Use on each of those parents, which means doing the same for all of their parents, if any (grandparents), recursively until it runs out of ancestors to "use" 😆

    The priority of conflicting settings is resolved in an order of lowest to highest, with parents all lower than child. (In other words, think of parents as a set of defaults that are inherited but can be overridden at will.)

    This test shows it in action.

    I did also have the idea that we could introduce global flags to set when using a backend.

    I like this idea a lot. It is sort of already possible with the --profile-include-args implementation in the current draft. In other words, if you have this config:

    [myremote]
    type = s3
    whatever = blah
    
    [s3]
    type = profile
    inplace = true
    arg_2 = myremote:
    

    then rclone copy some:path --use-profile s3 should be equivalent to rclone copy some:path myremote: --inplace
    (arg_2 as presumably the dest is what you care about with --inplace)

    But this does have some drawbacks -- you'd need to know in advance which arg number it would be, and it is also not very flexible if you want to use some other path at that remote.

    Tying global flags to remotes is a really interesting idea and I agree it would be useful. One question I have though is how conflicting flags would be handled in commands that use more than one remote. For example, suppose I sync two remotes, one of which has --checkers=8, the other of which has --checkers=16. How many checkers would be used for the sync? Another question to ponder: what if the src specifies dest-related flags like --inplace but the dest is silent on that flag -- is it used or ignored?

    Another possible implementation to consider: what if an Fs remote could take an optional profile parameter to call p.Use maybe during NewFs? Then the profiles code doesn't have to be concerned with going into other config sections and parsing them directly -- it is more of a pointer to where the settings are defined. Maybe that is what you were getting at with the parent profiles idea.

    I'll give this more thought, as I agree it would be quite handy! (A use that comes up for me a lot is wanting to use -c with backends that support checksums but omit it otherwise, to avoid the fallback to --size-only. It would be nice to be able to just put that -c in the config!)

    This is going to need lots of docs!

    Absolutely! That's a given.

    This should probably just be --profile (eg the aws command).

    I agree. I'll change it in the next draft.

    --profile-include-args to include the command's args in addition to flags (for example, two long paths that you sync regularly)

    This should probably default to true - if you put args in the profile then you'd expect to use them.

    My slight hesitation about this is that I'm not sure if that assumption also holds true when saving a profile. For example, if I do:

    rclone sync /some/path drive:somepath -MvP --create-empty-src-dirs --save-profile sync
    

    would you expect that to save the paths too? Or just -MvP --create-empty-src-dirs? If we reversed the default, would you have to do --profile-no-args to save only the flags?

  14. HorseLuke commented on Feb 22, 2024

    @HorseLuke

    @nielash Does it support stringArray in your implements? Some config flags can be passed multiple, eg --exclude, --ca-cert. Example: https://forum.rclone.org/t/rclone-exclude-not-working-for-multiple-rules/35200

  15. nielash commented on Feb 23, 2024

    @nielash
    Contributor

    @nielash Does it support stringArray in your implements? Some config flags can be passed multiple, eg --exclude, --ca-cert.

    Very good point! Yes, it should be supported, however it would be merged into one key in the config. For example:

    --exclude file1 --exclude file2
    

    would become:

    exclude = [file1,file2]
    

    The reason is because if you did this:

    exclude = file1
    exclude = file2
    

    it would be invalid INI (can't have duplicate keys in the same section)

  16. ncw commented on May 13, 2026

    @ncw
    MemberAuthor

    I have revived @nielash original code for this and given it a polish - any testing and comments much appreciated

    v1.75.0-beta.9733.5d3ed12fa.fix-2697-profiles on branch fix-2697-profiles (uploaded in 15-30 mins)

    Changes from the original

    • Rename --use-profile -> --profile
    • Rename --save-profile -> --profile-save
    • Rename --profile-include-args -> --profile-save-args (now save-only - saved args apply automatically at use time).
    • All four flags now share the --profile* namespace.
    • RCLONE_PROFILE=NAME env var now works
    • Removed the [default_profile] magic section - users set RCLONE_PROFILE or use a shell alias instead.
    • Added rclone config profile save / list / show / delete subcommands.
    • Dropped the top-level rclone setprofile command.
    • Profile sections now live under [profile:NAME] namespace (uses : which is illegal in remote names).
    • Dropped the type = profile field
    • Profile sections filtered out of listremotes, the config wizard's remote picker, and the rc /config/dump endpoint.
    • A remote [backup] and a profile [profile:backup] now coexist without conflict; checkNameConflict removed.
    • Dropped the fake fs.Register({Name:"profile", NewFs: nope, …}) pseudo-backend.
    • Dropped the profileConfig state machine and EditProfiles interactive wizard.
    • In-memory Profile.Flags keys are now canonical snake_case
    • Replaced the ~600 lines of cmd.Root/bisync/fstest scaffolding with unit tests against a small synthetic *cobra.Command.
    • New "Profiles" section in docs/content/docs.md

    Here are the updated docs

    Profiles {#profiles}

    Profiles let you save a named set of flags (and optionally arguments)
    in the config file and reuse them on later command lines, so you
    don't have to retype long flag combinations every time.

    For example, if you regularly sync a directory to Google Drive with a
    specific set of flags, you can save that combination once as a
    profile and from then on use --profile mybackup instead.

    Saving a profile

    Add --profile-save NAME to any rclone command. The command will run
    as normal, and rclone will additionally write all the explicitly-set
    flags from that command line into the config file under a new section
    named [profile:NAME]. The profile: prefix is the namespace
    profiles live in - because : is illegal in remote names, a profile
    called backup and a remote called backup can coexist without
    colliding.

    For example:

    rclone sync src: dst: --checkers 16 --transfers 8 --metadata --profile-save fast-sync

    writes:

    [profile:fast-sync]
    checkers = 16
    transfers = 8
    metadata = true

    Only flags whose values you explicitly changed are saved - flags left
    at their default are not.

    The profile-control flags themselves (--profile-save, --profile,
    --profile-save-args, --profile-strict-flags) are never saved
    into the profile. --config is also excluded - it's
    environment-specific and would re-point the config storage mid-load
    when applied from a profile.

    Using a profile

    Add --profile NAME to apply a saved profile:

    rclone sync src: dst: --profile fast-sync

    This is equivalent to repeating all the flags from the saved profile
    on the command line.

    You can apply several profiles in one go by passing a comma-separated
    list. They are applied in lowest-to-highest priority order, so later
    profiles override earlier ones:

    rclone sync src: dst: --profile common,fast-sync

    Any flag you pass explicitly on the command line overrides the
    profile's value for that flag, so you can use a profile as a baseline
    and tweak individual values for one run.

    For safety, a profile can never turn off --dry-run if it was set
    explicitly on the command line.

    Including command arguments

    By default --profile-save only saves flags. If you also want to
    save the positional arguments (e.g. the source and destination paths)
    add --profile-save-args:

    rclone sync /local/path remote:backup --profile-save nightly --profile-save-args

    When the profile is later used, saved arguments are applied
    automatically - you don't need to pass anything extra at use time.
    If you pass your own positional arguments on the command line, they
    take precedence over the profile's saved ones (the profile only
    fills slots you didn't provide).

    Strict flag checking

    When you save a profile from one command (say sync) and then apply
    it to another (say copy), the profile may contain flags that don't
    exist on the new command. By default these flags are silently
    ignored. Pass --profile-strict-flags to make rclone error out
    instead of skipping them.

    Command-specific flags

    Profiles work with the flag set of the command they're saved from
    and applied to, so command-specific flags (e.g. the VFS
    flags
    on rclone mount, or
    bisync's --resilient) are saved and loaded just like global flags:

    rclone mount remote: /mnt --vfs-cache-mode full --dir-cache-time 24h \
        --profile-save media-mount
    
    rclone mount remote: /mnt --profile media-mount

    The resulting section looks like any other profile:

    [profile:media-mount]
    vfs_cache_mode = full
    dir_cache_time = 24h0m0s

    If you later apply this profile to a different command that doesn't
    have those flags (e.g. rclone copy --profile media-mount), the
    VFS flags are silently skipped - or rejected if you also pass
    --profile-strict-flags.

    To build a profile for command-specific flags without actually
    running the command, use rclone config profile save NAME --flags-from CMD:

    rclone config profile save media-mount --flags-from mount \
        --vfs-cache-mode full --dir-cache-time 24h

    Inheriting from parent profiles

    A profile can inherit settings from one or more parent profiles by
    listing them in parent_profiles in the config:

    [profile:shared]
    checkers = 16
    metadata = true
    
    [profile:nightly]
    parent_profiles = shared
    transfers = 4

    Parent names are also given in their user-facing form (without the
    profile: prefix).

    Using --profile nightly first applies shared, then applies
    nightly on top, so nightly overrides any flag the two have in
    common. Parents themselves can have parents - profiles are resolved
    recursively.

    Always applying a profile

    There is no "default profile" mechanism - if you want a profile to
    apply every time, set it in the environment instead:

    export RCLONE_PROFILE=mybackup

    --profile is exposed as a standard rclone option, so the
    RCLONE_PROFILE environment variable Just Works. Use a shell
    alias or wrapper script if you want different defaults in different
    contexts. This keeps "what flags am I actually running with" answerable
    from the command line and environment alone, with no spooky action
    from the config file.

    Managing profiles

    Use the rclone config profile subcommands to manage profiles
    without editing the config file by hand:

    rclone config profile save NAME [args...] [flags...]
    rclone config profile list
    rclone config profile show NAME
    rclone config profile delete NAME
    • save writes a new profile from the flags (and optional positional
      args, with --profile-save-args) given on the command line.
      Pass --flags-from CMD[,CMD...] to make flags from other commands
      (e.g. mount, bisync) available for saving without having to
      actually run those commands.
    • list prints the names of all profiles in the config file.
    • show prints the keys and values stored in one profile.
    • delete removes a profile.

    To edit an existing profile, either re-save it (overwriting the old
    one) or edit the corresponding [profile:NAME] section in the
    config file by hand.

    Config file layout

    Profiles live under the [profile:NAME] namespace in the config
    file. The profile: prefix is the canonical signal that a section
    is a profile - : is illegal in remote names, so profiles and
    remotes can share a name without colliding. Profile sections are
    hidden from rclone listremotes, rclone config show <remote> and
    the rc API's config/dump (they don't appear as remotes).

    Saved flags are written with their option name in snake_case (e.g.
    drive-skip-gdocs becomes drive_skip_gdocs = true). Saved
    arguments are written as arg_1 = ..., arg_2 = ... and so on.

  17. nielash commented on May 13, 2026

    @nielash
    Contributor

    This is so exciting!!!

    • Removed the [default_profile] magic section - users set RCLONE_PROFILE or use a shell alias instead.

    I slightly question this one... it was intended for a specific use case where the user has access to the config file but not env vars or command line flags. There is an example earlier in this thread, and it's a scenario that could start to become more common with the increasing number of "Rclone GUI" wrapper apps that seem to be popping up lately.

    On the other hand, perhaps the better answer is for those apps to allow selecting a profile to use!

    Thank you for reviving this! Haven't tested it out yet, but at a quick glance the changes look great!

  18. nielash commented on May 14, 2026

    @nielash
    Contributor

    I'm playing around with it now and think I found a small bug relating to command-specific flags.

    The docs suggest that this should work:

    rclone mount remote: /mnt --vfs-cache-mode full --dir-cache-time 24h \
        --profile-save media-mount
    

    But for me it results in:

    unknown flag: --vfs-cache-mode
    

    Similarly:

    rclone copy a b -MvP --create-empty-src-dirs --profile-save testing --profile-save-args    
    

    gives:

    unknown flag: --create-empty-src-dirs
    

    Same command omitting --create-empty-src-dirs works as expected.

  19. nielash commented on May 14, 2026

    @nielash
    Contributor

    Also an oddity with the --verbose flag.

    rclone mkdir /some/path/a -v --profile-save testing
    

    shows DEBUG logs, when I would expect INFO.

  20. ncw commented on May 21, 2026

    @ncw
    MemberAuthor

    This is so exciting!!!

    :-)

    • Removed the [default_profile] magic section - users set RCLONE_PROFILE or use a shell alias instead.

    I slightly question this one... it was intended for a specific use case where the user has access to the config file but not env vars or command line flags. There is an example earlier in this thread, and it's a scenario that could start to become more common with the increasing number of "Rclone GUI" wrapper apps that seem to be popping up lately.

    The implementation was a bit too magic for my taste with one profile referencing another. Maybe we should just have a profile called default instead?

    On the other hand, perhaps the better answer is for those apps to allow selecting a profile to use!

    I was thinking about this feature in general in relation to the arg_N feature. We don't allow storing of the command running (eg ls or mount) which I think is a good decision, but it means that there will always be some arguments.

    So at minimum a command is going to be rclone copy --profile myprofile

    If we have default profile then that could be rclone copy

    If we allowed storing the command too then that could be rclone.

    I don't think we should allow storing the command, but would be interested to hear what you think.

    I'm playing around with it now and think I found a small bug relating to command-specific flags.

    Those should be fixed now!

    Also an oddity with the --verbose flag.

    That is fixed also.

    That was to do with applying the flags twice which brings up another problem with flags you can repeat - eg --header. These also don't round trip to and from the config file - maybe we should just disallow them for the moment?

  21. nielash commented on May 23, 2026

    @nielash
    Contributor

    The implementation was a bit too magic for my taste with one profile referencing another. Maybe we should just have a profile called default instead?

    I think that's a reasonable solution.

    I don't think we should allow storing the command, but would be interested to hear what you think.

    I agree about not storing the command.

    I think the use case for the default profile (and perhaps someone here who actually needs it can articulate it better) is something like a GUI wrapper app that hardcodes something like rclone copy a: b:, with a: and b: referencing the user-supplied config. If you wanted to add filters or something, you'd have to somehow set them in the config, as the env vars and flags are hardcoded. I don't think the user would be looking to override the command itself.

    Those should be fixed now!

    Yay!

    That was to do with applying the flags twice which brings up another problem with flags you can repeat - eg --header. These also don't round trip to and from the config file - maybe we should just disallow them for the moment?

    I wouldn't necessarily miss --header but there are others I probably would miss, like --filter. What about the solution I proposed here?

  22. nicollasricas commented on Jul 25, 2026

    @nicollasricas

    Hey @ncw, should I open a new issue for the problem with the --profile argument when using serve mentioned here, or do you think it won't be necessary?

    It seems that the --profile argument might not even be needed once the default profile implementation is complete.

  23. added a commit that references this issue on Nov 21, 2026
    d18889b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions