Replicating Kirby content with rsync and cron

For all of my Kirby projects the content folder usually is excluded from the Git repository, and hence the content does not get deployed with new releases. To create a development preview that always features the latest content from the production site…


This content originally appeared on foobartel.com :: Stream and was authored by foobartel.com :: Stream

For all of my Kirby projects the content folder usually is excluded from the Git repository, and hence the content does not get deployed with new releases. To create a development preview that always features the latest content from the production site, I recently set up a cron job that replicates the Kirby content directory from its production location to the develop environment.

This is a simple one-liner which makes working with the development site more convenient, because any new features or bugfixes can be previewed and tested with the latest content from the live site.

For the replication to happen, I’m using a simple shell script which then gets called via a cron job at a certain time interval. I think case I’m running the script once a day, but it’s possible to tweak the cron job interval to your own liking and requirements.

To copy the content folder I’m using rsync (documentation), which is an open-source utility for transferring and synchronizing files.

The simple syntax for the command is: rsync [OPTION...] SRC... [DEST]

Since cron will be calling the rsync command as a shell script, the script starts with a hashbang.

To copy the complete content directory with all of its content, it's required to use the -r (or --recursive to recurse into directories) option.

The complete script then looks like this:

#!/bin/sh rsync -r /production.domain.tld/content /develop.domain.tld/

The last step then is to save the script on the server (e.g. as “replicate-content.sh”), set its permissions to be executable and call it with a cron job. Many hosting plans come with an interface to create and configure cron jobs, otherwise it’s neccessary to create one from scratch.

As a result, the above script will be automatically executed at the set interval (e.g. every day at midnight) and copy the complete content directory and all of its subdirectories to the development server.


This content originally appeared on foobartel.com :: Stream and was authored by foobartel.com :: Stream


Print Share Comment Cite Upload Translate Updates
APA

foobartel.com :: Stream | Sciencx (2021-11-17T23:00:00+00:00) Replicating Kirby content with rsync and cron. Retrieved from https://www.scien.cx/2021/11/17/replicating-kirby-content-with-rsync-and-cron/

MLA
" » Replicating Kirby content with rsync and cron." foobartel.com :: Stream | Sciencx - Wednesday November 17, 2021, https://www.scien.cx/2021/11/17/replicating-kirby-content-with-rsync-and-cron/
HARVARD
foobartel.com :: Stream | Sciencx Wednesday November 17, 2021 » Replicating Kirby content with rsync and cron., viewed ,<https://www.scien.cx/2021/11/17/replicating-kirby-content-with-rsync-and-cron/>
VANCOUVER
foobartel.com :: Stream | Sciencx - » Replicating Kirby content with rsync and cron. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/17/replicating-kirby-content-with-rsync-and-cron/
CHICAGO
" » Replicating Kirby content with rsync and cron." foobartel.com :: Stream | Sciencx - Accessed . https://www.scien.cx/2021/11/17/replicating-kirby-content-with-rsync-and-cron/
IEEE
" » Replicating Kirby content with rsync and cron." foobartel.com :: Stream | Sciencx [Online]. Available: https://www.scien.cx/2021/11/17/replicating-kirby-content-with-rsync-and-cron/. [Accessed: ]
rf:citation
» Replicating Kirby content with rsync and cron | foobartel.com :: Stream | Sciencx | https://www.scien.cx/2021/11/17/replicating-kirby-content-with-rsync-and-cron/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.