Added tightvnc for headless GUI.
http://www.penguintutor.com/linux/tightvnc
... Robert
Monday, September 24. 2012
TightVNC For Headless Pi GUI
Backing Up the Raspberry Pi Blog
It would be a shame to lose everything I have put into the Raspberry Pi blog so it's time to put in a backup regime.
Strategy
The Raspberry Pi blog is located both both '/var/www/raspberrypi/' and in the serendipity-db catalog of the local MySQL database. We will need to backup up both to completely cover ourselves.
The strategy for backup will be to make archives of both the filesystem and the mysql database, archive them together and then copy to the network drive under a unique filename. The backup will be run from a script which which will live in the '/var/www' directory and be regularly run from an entry in the '/etc/crontab' file.
During the backup process I will create temporary files on the network drive to avoid wear on the local SD card.
We first setup NFS or SAMBA networking and ensure we have mounted our network storage device at a suitable mount point. I have chosen NFS in this example. To use Windows networking adapt the instructions below accordingly.
1. Install NFS client (checked already installed as part of the Weezy distribution).
2. Make a mount point for backups at '/var/www/backup' and add edit '/etc/rc.local' to mount our external resource on boot by adding the following line 'mount -t nfs -o nolock [IP address or hostname of your NAS server]:/var/local/www /var/www/backup'
Backup Script
Here is my script. Note the use of the file '/var/www/backup/sync_www' to ensure we have mounted the network drive and are not just working with our local mount point.
A brief description pf the steps of the script are as follows
1. Check to see we have mounted the network drive by looking for a file called 'sync-www' which we have alread place on the network drive.
2. Create our target backup directory if it does not already exist.
3. Change to the '/var/www/' as our working directory.
4. Create a dated temporary archive of the files in '/var/www/raspberypi'
5. Create a dated temporary archive of the mysql data dumped from the catalog 'serendipity-db'
6. Create the final backup archive removing the temporary working files.
Handling Erorrs
Note the use of '&& \' after each line ensures that the next line only executes if the previous command was successful otherwise the script exits with error code 1.
Note this script could be further enhanced with email notifications of success or failure as needed.
Scheduling
Finally the following entry in '/etc/crontab' will ensure this script runs daily at 2:30 am.
... Robert
Strategy
The Raspberry Pi blog is located both both '/var/www/raspberrypi/' and in the serendipity-db catalog of the local MySQL database. We will need to backup up both to completely cover ourselves.
The strategy for backup will be to make archives of both the filesystem and the mysql database, archive them together and then copy to the network drive under a unique filename. The backup will be run from a script which which will live in the '/var/www' directory and be regularly run from an entry in the '/etc/crontab' file.
During the backup process I will create temporary files on the network drive to avoid wear on the local SD card.
We first setup NFS or SAMBA networking and ensure we have mounted our network storage device at a suitable mount point. I have chosen NFS in this example. To use Windows networking adapt the instructions below accordingly.
1. Install NFS client (checked already installed as part of the Weezy distribution).
2. Make a mount point for backups at '/var/www/backup' and add edit '/etc/rc.local' to mount our external resource on boot by adding the following line 'mount -t nfs -o nolock [IP address or hostname of your NAS server]:/var/local/www /var/www/backup'
Backup Script
Here is my script. Note the use of the file '/var/www/backup/sync_www' to ensure we have mounted the network drive and are not just working with our local mount point.
#!/bin/sh
if [ -e /var/www/backup/sync_www ]; then
mkdir -p /var/www/backup/raspberrypi/
cd /var/www/
tar --exclude-vcs -czf ./backup/raspberrypi/raspberrypi-www_`date +%y_%m_%d`.gz raspberrypi && \
mysqldump -u YOUR_MYSQL_USERNAME_HERE -pYOUR_MYSQL_PASSWORD_HERE serendipity-db | gzip > ./backup/raspberrypi/raspberrypi-mysqldump_`date +%y_%m_%d`.gz && \
tar --remove -cf ./backup/raspberrypi/raspberrypi-blog_`date +%y_%m_%d`.tar ./backup/raspberrypi/raspberrypi-www_`date +%y_%m_%d`.gz ./backup/raspberrypi/raspberrypi-mysqldump_`date +%y_%m_%d`.gz
exit 0
else
exit 1
fi
A brief description pf the steps of the script are as follows
1. Check to see we have mounted the network drive by looking for a file called 'sync-www' which we have alread place on the network drive.
2. Create our target backup directory if it does not already exist.
3. Change to the '/var/www/' as our working directory.
4. Create a dated temporary archive of the files in '/var/www/raspberypi'
5. Create a dated temporary archive of the mysql data dumped from the catalog 'serendipity-db'
6. Create the final backup archive removing the temporary working files.
Handling Erorrs
Note the use of '&& \' after each line ensures that the next line only executes if the previous command was successful otherwise the script exits with error code 1.
Note this script could be further enhanced with email notifications of success or failure as needed.
Scheduling
Finally the following entry in '/etc/crontab' will ensure this script runs daily at 2:30 am.
'30 2 * root /var/www/backup-www.sh &'
... Robert
(Page 1 of 1, totaling 2 entries)