Sync Kirby’s content folder with rsync

This is primarily a note to myself. Nevertheless, it might help others.

I write my blog posts directly online in the Kirby backend. With Kirby Blocks and all the keyboard shortcuts and navigation options it offers, I can work quite quickly here. When testing in my local development environment, I often just create stupid test pages with “Lorem ipsum” content. To have the current status of the content folder locally from time to time, I use rsync. Unlike Maurice, who uses a very sophisticated system to synchronize between his Kirby installation and Obsidian, this simple one-way backup function is sufficient for me.

#!/usr/bin/env bash

rsync -chavzP --delete --stats my-ssh-alias:/var/www/html/my-kirby-website/content /path/to/local-websites/my-kirby-website
Option
-c --checksum
-h --human-readable
-a --archive
-v --verbose
-z --compress
-P --progress
--delete
--stats

The --delete flag removes all test content locally which does not exist on the server. In this way I don’t have to clean up by myself. In addition --stats gives a nice summary at the end about how much data has been transferred.

There are a million more options for rsync which makes it a really powerful tool.

Script file

Of course, I don't type this command into the terminal over and over again. I put it into a file, made it executable and reuse it whenever I want. Here’s a nice overview how to create custom scripts. It refers to Linux, but is also valid for MacOS.

Links


Kirby Helper #rsync #Backup

Related

Featured

It‘s the rests what makes the groove!

Matthias Ott recently published a blog post which really resonates with me. Starting from a musical point of view, he wrote about making space. This is my reply (or addition).

Random

A different approach to the Kirby content() method?

pageview counter pixel