Directoryless rsync synchronization

Well, I'm probably not the first person trying to combine PHP web interface for rsync to simplify deployment, but it goes there.

We have a "QA" server locally and a "Staging" server in Rackspace. I installed SSH key pairs so that I can rsync between the two servers, and all this works fine. The problem is that rsync is a little flaky regarding what it decides needs to be updated.

The script I wrote at the beginning executes rsync with the "-dry-run" parameter to get a list of everything you need to transfer. The command is as follows:

$strCheck = shell_exec( "rsync " . "--verbose " . "--recursive " . "--safe-links " . "--checksum " . "--dry-run " . "--delete " . "--delete-excluded " . "--force " . "--cvs-exclude " . "--human-readable " . "/apps/{$system}/ " . " user@liveserver :/apps/{$system}_staging/" ); 

Now everything works fine, and I can parse the string that returns to the material that needs to be removed, and the material that needs to be added / updated. Then I create an HTML table that automatically discards each checkbox based on where it is in the hierarchy. I also use a bit of javascript, so I can allow the user to select all the files in the folder.

If the folder itself needs to be added / deleted, it includes it in the list. For instance:

 /newfolder/ /newfolder/file1.php /newfolder/file2.php 

which is great, because "/ newfolder /" will be displayed with one indent, and "/newfolder/file1.php" and "/newfolder/file2.php" will be displayed with two indentation under "/ newfolder /", The checkbox next to ' / newfolder / 'will automatically select two child files and everyone will be happy.

However, if he simply adds / updates files to a folder, he omits the folder itself:

 /oldfolder/filea.php /oldfolder/fileb.php 

...

This means that all files in '/ oldfolder /' will have two indentation, but there is no visible mechanism for selecting all files in a folder.

So my question is this: is there something missing from the rsync options available where I can make it include a folder for any updated files, or will I have to add them when I go through the array? If this is the last, what would be the best way to do this?

Help me Obi-stack Overflows, you are my only hope ...

+4
source share
1 answer

Since the directory does not need to be created or deleted, it will not be on the rsync list. I do not believe that there is a way to fix this.

I think your best bet is to get something like this

$path = explode(PATH_SEPARATOR, dirname($filename) );

Where $ filename is your filename.

+2
source

All Articles