SilverStripe 3 syncing assets directory

In our workflow we often find ourselves needing to sync our different environments like a live deployment and a staging environment.  Unlike some other cms platforms, SilverStripes database transfers very easily.  We use a tool called Navicat to first dump one database and then to execute the resulting .sql file on the other database.  This of course could simply be done via the command line (which is better for large databases too).

The database isn't the only thing we have to move to sync the two sites of course.  The asssts/ directory also needs to be synced and this can often be a bit of a chore.  You can of course rm one environments assets folder and copy the others in, but this can take some time.  Instead we use a command that recursively updates the files so we can ignore anything the two folders have in common.

 

Adjust paths to your webroot:

sudo cp -ur /var/www/hmtl/live_site/assets/* /var/www/hmtl/staging_site/assets/

You then need to update ownership and permissions on the folder that was synced to:

sudo chown -R www-data:www-data /var/www/hmtl/staging_site/assets/
sudo chmod -R 755  /var/www/hmtl/staging_site/assets/

 

Happy syncing!