I'm following along with a Railscast that teaches how to set up Chef solo. It uses two interesting terminal commands that I had never seen before, only one of which I can get to work. When I do

scp -r [email protected]:/var/chef .

It copies the contents of the remote server directory to my local machine. The following command is supposed to sync the files back to the server after I change them on my machine

rsync -r . [email protected]:/var/chef

However, the changes aren't showing on the remote server, and when I run the chef commands that are supposed to apply the changes, it's not showing any changes that need to be made.

Am I using rsync incorrectly?


Running this command gave the following output. Still no changes are shown on the remote server

rsync -rvv . [email protected]:/var/chef

`building file list ... 
delta-transmission enabled
total: matches=17  hash_hits=17  false_alarms=0 data=0
sent 1167 bytes  received 442 bytes  643.60 bytes/sec
total size is 6236  speedup is 3.88`


You'll notice from the above update that a templates directory should be inside the main directory (along with a recipes directory), however, this is what's showing

root@Chef3:/var/chef/cookbooks# cd main
root@Chef3:/var/chef/cookbooks/main# ls
  • What's the output of rsync -rv . [email protected]:/var/chef? You are indeed using rsync incorrectly (not your fault, looks like a bad tutorial), but not in a way that should cause the changed files not to be transferred. Jul 21, 2013 at 0:22
  • Thanks, It says, "building file list ... done" and then it lists the files. However, they still haven't been copied to the remote server (at least the changes aren't apparent on the remote server)
    – Leahcim
    Jul 21, 2013 at 0:25
  • 1
    Is that the list of all the files in the directory? If not, which ones are missing? Are you sure the edited files aren't being transmitted? Jul 21, 2013 at 0:58
  • 1
    I have my money on 1 of 2 things: no diskspace to write files or the files are there.
    – slm
    Jul 21, 2013 at 1:00
  • 2
    @Leahcim Are there symbolic links involved? Please post the output of ls -ld * chef/node.json. Is it normal that you have a chef directory inside the chef` directory | could that be causing the confusion? Jul 21, 2013 at 1:58

1 Answer 1


You have two file hierarchies mixed up: /var/chef and /var/chef/chef. It looks like you're editing one and then reading back the other.

scp -r [email protected]:/var/chef . creates a chef directory inside the current directory. If you ran that from /var/chef.

The proposed commands are terrible. Forget everything you read in that tutorial.

scp -r does not preserve file permissions or times. Use scp -rp to preserve them.

rsync -r does not preserve file permissions or times. Forget that the -r option exists. Use rsync -a instead, which preserves all usual metadata. Always pass the -a option to rsync unless you have a good reason not to.

When you write rsync -a /path/to/source /path/to/destination, this creates a subdirectory called source under destination. If you want to synchronize /path/to/source with /path/to/destination instead, add a final / at the end of the destination: rsync -a /path/to/source /path/to/destination/ copies /path/to/source/somefile to /path/to/destination/somefile.

It's very important to preserve the file's modification times. That way you know when a file has last been modified. Your tools also know when a file has been modified. In particular, synchronizing a large directory in which most files haven't been modified is a lot faster if the file times are reliable. Rsync will skip a file quickly if the name, size and modification time are the same on both sides.

You can tell rsync to transfer only files that are newer on the source side by adding the -u option (rsync -au SOURCE DESTINATION). This limits the risks if the files have also been edited on the destination side: you won't erase the newer version that is on the destination side with the older copy on the source side. However you cannot reliably detect conflicts: if a file has been edited on both sides, whichever version has the most recent modification time will win.

Rsync is a tool to synchronize data in one direction. Do not use it to synchronize in both directions. Instead, use Unison. Unison maintains a list of file versions each time you run it and will complain loudly if there is ever a conflict (same file edited independently on both sides). As long as there is no conflict (i.e. as long as each file is only modified on one side between synchronizations), Unison will merge the changes on the two sides.

To set up Unison, use the GUI, or create a preferences file called ~/.unison/chef.prf containing

root = /var/chef
root = server.example.com:/var/chef
times = true

Run unison -auto chef to synchronize the two trees.

Rather than synchronizing files, you should put your files under version control. When you've made changes, commit them to the repository. To deploy your changes, check them out on the server.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .