Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 481801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T01:01:53+00:00 2026-05-13T01:01:53+00:00

OK, I’m probably not the first person to attempt to put together a PHP

  • 0

OK, I’m probably not the first person to attempt to put together a PHP web-based interface to rsync to ease deployment, but there goes.

We have a ‘QA’ server locally and a ‘Staging’ server at Rackspace. I’ve set up SSH key pairings so I can rsync between the two servers and it all works great. The problem is that rsync is a bit flaky as to what it decides needs updating.

The script I have written first executes rsync with the ‘–dry-run’ parameter to get a list of everything that needs transferring. 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 this all works fine and I can parse the string that’s returned into stuff that needs deleting and stuff that needs adding/updating. I then construct a HTML table that automatically indents 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 files in a folder.

If a folder itself is to be added/deleted, it includes it in the list. For example:

/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 each be displayed with two indents underneath ‘/newfolder/’. The checkbox next to ‘/newfolder/’ will automatically select the two ‘child’ files and everyone is happy.

However, if it is just adding/updating files to a folder, it omits the folder itself:

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

…

Which means all the files in ‘/oldfolder/’ will have two indents, but there is no visible mechanism with which to select all the files in the folder.

So my question is this: is there something I am missing in the available rsync parameters where I can force it to include the folder for any updated files, or am I going to have to add them in as I loop through the array? If it’s the latter, what would be the best way of doing that?

Help me Obi Stack Overflowbi, you’re my only hope…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T01:01:53+00:00Added an answer on May 13, 2026 at 1:01 am

    Since the directory does not need to be created or deleted it will be missing from the list rsync returns. I don’t believe there is any way to fix that.

    I think your best bet would be to get the paths something like this


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

    Where $filename is your files name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.