1

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

I have set up a web server, and a website on my Raspberry Pi device (LAMP, PHP-MySQL site). I 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 the webroot folder.
  2. Make updates to the raspberry pi device remotely as well. e.g. update PHP, Apache modules whenever 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.

2
  • 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
    Commented May 7, 2014 at 15:30
  • Looks like this question should be on unix.stackexchange.com or serverfault.com. Not specific to RPi. Commented Sep 3, 2014 at 10:14

2 Answers 2

3

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.

3

For the second part:

Doing an unattended upgrade can have interesting side-affects. As in a system failure. Not recommended. Instead, I would recommend running a periodic cron job to see what your distribution is offering.

If an apt capable system:

# In /etc/crontab  Running at ferinstance 13:13 on Mondays
13 13 * * 1  root  apt-get update && apt-get -d dist-upgrade

This assumes that 'root' mail comes to you for review.

If you REALLY want to fly with an unattended upgrade:

# NOT RECOMMENDED
# In /etc/crontab  Running at ferinstance 14:14 on Thursdays
14 14 * * 4  root  apt-get update && apt-get -y upgrade

Note:

  1. The '-d' option causes a package download only. It does not do an upgrade. If used, the '-y' option forces a 'yes' to questions.
  2. I'd use only the 'upgrade' command option as the 'dist-upgrade' option can result in unexpected results e.g. removal of customized config files, changes to your critical utilities, a full upgrade with reboot required, etc...
  3. Make sure you are using the current release name and NOT the 'stable' designator.in your sources.list(s)

In any event: Carefully review the job output...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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