1

I have a local folder on my Mac that I want to sync with a WebDAV server.

There are a lot of files in my folder. After I edit some files or add/remove folders, I want to be able to sync the changes to the WebDAV server, ignoring what it is on the server and always using my files.

Is there any script or tool that I can use from command line to do that?

And mounting the resource is not a solution.

Skyhawk
  • 14,200
  • 4
  • 53
  • 95
daniels
  • 1,205
  • 5
  • 16
  • 26
  • 3
    What operating system are you using? Would you care to elaborate as to why mounting the resource cannot be part of the solution? – Skyhawk Apr 12 '12 at 21:30
  • Mac OS X, so any *nix solution should work. I don't want to use mount as i need to have a local copy of the files as the files form webdav can be deleted/altered anytime, so i need my local copy and just sync when needed. – daniels Apr 12 '12 at 22:04
  • @daniels What does that have to do with mounting or not mounting the share? – Shane Madden Apr 12 '12 at 22:15
  • If i mount the files then i would edit them directly from there, right? I still need to have a local copy of the files, so should i just mount and then copy & paste from one place to another? – daniels Apr 12 '12 at 22:25
  • 1
    Hold on. If you prefer a GUI solution like copying and pasting, why not just use Cyberduck and be done with it? It's easy to configure your upload preferences to skip existing files. – Skyhawk Apr 13 '12 at 01:01

3 Answers3

2

Mounting the resource isn't the total solution, but it can be part of it.

If you mount the WevDAV share, you can use robocopy /mir to mirror the contents of one directory to another. This should take care of your problem. Robocopy is well documented and highly script-able.


Edit: Since apparently you're on a Mac (minor detail, right?), you can just replace robocopy with rsync. It will still work the same.

MDMarra
  • 100,734
  • 32
  • 197
  • 329
  • Seems like it could work but i am on mac so i can;t use robocopy – daniels Apr 12 '12 at 22:07
  • 4
    Well, good thing you included that information in your question since we're not mind readers...oh wait. – MDMarra Apr 12 '12 at 22:08
  • No need to be upset here man, i just forgot this detail, and i did appreciated your answer and up voted it as it is a valid solution even if it is not in my case. So thanks. – daniels Apr 12 '12 at 22:23
1
rsync -a /source user@ssh_host:/path/to/destination

That'll do it right there. rsync also will only transfer those files which have changed. It is HIGHLY recommended that you not use rsync (or any copy method) on any active database file. For example, for MySQL, it is recommended that you use mysqldump to export the database to a text file beforehand.

UtahJarhead
  • 928
  • 7
  • 14
0

You appear to be massively over-thinking this and by doing so are overlooking some really obvious solutions.

You say mounting is not a solution and then proceed to explain that this is because you think that by mounting the webdav folder you will be working with the remote documents directly. Have you considered mounting the remote folder AND having a local folder? Then you simply do your editing locally and when ready merely copy the contents to the webdav folder.

John Gardeniers
  • 27,458
  • 12
  • 55
  • 109
  • The files are code files. I most of the time i edit as much as a line of code then i need to upload it on webdav to see how it works and so on. And i have lots of files in lots of folders so just copying the files from one place to another at each small change will be a huge waste of time. – daniels Apr 13 '12 at 07:14
  • 1
    @daniels, then mount the wevdav folder, do your editing and use any file/folder sync tool to update your changes. – John Gardeniers Apr 14 '12 at 10:33