0

I am trying to merge a folder with files in source location to a folder with files in destination location and instead of just copying files / overwriting, salt just wipes out the destination

  file.copy:
    - name: D://
    - source: D://Staged/Folder
    - force: True
    - makedirs: True
    - subdir: True
    - preserve: True

So I am trying to copy folders/files from D://Staged/Folder to D://Folder (D://Folder already exists with folders and files) Instead everything inside D://Folder gets wiped out

user1173894
  • 55
  • 2
  • 9

1 Answers1

0

Sounds like you want to copy files from the source directory to destination irrespective of its existence and contents.

Since you are using a "state" module, it will try to match the state of your destination path to the one given in source. See this question for example on difference between state and execution modules.

You could instead use the file.copy execution module for this purpose:

copy_files:
  module.run:
    - file.copy:
        - src: D:/Staged/Folder
        - dst: D:/Folder
        - recurse: True

As with an execution module, this will run every time. Even if the source and destination directories have the same contents.

seshadri_c
  • 6,906
  • 2
  • 10
  • 24