I recently started working with Raspberry Pi, and am in general a novice in working with Linux.

I have setup web server, and a website on my Raspberry Pi device (LAMP, PHP-MySQL site). I would want to achieve the following:

  1. Update the site (PHP files) routinely via script. The script can check updates from our servers, and if an update is available, download and replace the files in webroot folder.
  2. Make updates to raspberry pi device remotely as well. e.g. update PHP, Apache modules when ever an update is available.

Do note, that the pi device might not be in a network I am in. The server urls will be fixed though. I want the device to check and communicate with the server.

  • For No.1 it sounds liked you want the pi to 'pull' in the 'latest version' of all files in web root. A git repo is what many people might use, although it may not cover your No.2 point. – drgrog May 7 '14 at 15:30
  • Looks like this question should be on unix.stackexchange.com or serverfault.com. Not specific to RPi. – Morgan Courbet Sep 3 '14 at 10:14

First Part

For the first part of the question: there are a number of solutions that are regularly used on Linux/Unix machines for that sort of task. Some of them are even file system-level replication, like CODA, AFS etc. They aren't very widely used, though, but possible.

Another one is to just export the file system from one host to the other, using NFS, which is a type of file system and gets mounted when Linux boots, or WebDAV which needs an apache module or some other solution on the server side and gets mounted by the client the same way. These solutions are susceptible to downtime and data loss due to lack of redundancy: if the server crashes the files become unavailable. You can also use windows-born protocols like CIFS or the old SMB. iSCSI is also a newer option. All then them susceptible to the crashing-server downtime issue.

The most used solution for that task is a file-level replication application such as rsync. rsync will mirror the files from a server and make incremental updates, changing only the files that were altered on the server. It is pretty standard and easy to setup and learn. There are other options, of course, and searching for rsync will show you many of those.

Second Part

This seems to be distro-specific if you choose to use distribution provided packages for your server applications.

On Raspbian, which uses debian's dpkg tools like apt, aptitude and others, you can easily setup a cron job ("man cron" and "man crontab" on your pi console) that will execute a "apt-get update" and "apt-get upgrade" to keep everything up-to-date.

This solution does not come without risks though. Auto-upgrading can, rarely, break your setup and need operator attention. If it is in auto mode and unsupervised, you might run into downtime from time to time.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.