Saturday, 2 July 2011
Updated NFS backup script
After some searching and playing with SH (beware! different from BASH) scripts, I came up with this solution:
#!/bin/sh
/usr/bin/MountSaturnBackup
sleep 2
DT=`stat -f -L -c %T /mnt/backup`
if [ "$DT" = "nfs" ]; then
tar cpf /mnt/backup/FullBackup.tar --same-owner --exclude=/network/backups/Jupiter --exclude=/var/cache/zoneminder/events/* --exclude=/proc/* --exclude=/media/* --exclude=/d$
fi
The correct thing to do would be to add an else statement and have the script send me an email. I'll look at that later....
Monday, 17 August 2009
DaviCAL installation
Fed up with waiting for Snow Leopard I decided to set up a calender server on our Linux server. After some searching I found out that Davical would be the best solution, especially since we use thunderbird and would like to use lightning as a calerdar client.
I installed DaviCAL on our Ubuntu 7.10 server, this was not very easy! All in all I can't even rember how I exactly did it. My plan is do to the same on a second server and document this step by step.
Most important thing for me is that is all works! There are some disadvantages, but none to big.
Some things to watch out for:
- In the permissions file of PostgreSQL (pg_hba.conf), make sure to post the access control rule at the top of the configuration document!
- The username in the caldav access URL is casesensitive!
- Use this as URL: http://
/ /caldav.php/ /home/
Since DaviCAL uses PostgreSQL instead of MySQL a extra backup routine is important for me. Our MySQL database is backup, so I added an extra backup script:
#################################################################################################
# PostgresSQL Backup:
mv /network/backups/Database_Backup/Daily6_PostgreSQL_DaviCAL.sql /network/backups/Database_Backup/Daily7_PostgreSQL_DaviCAL.sql
mv /network/backups/Database_Backup/Daily5_PostgreSQL_DaviCAL.sql /network/backups/Database_Backup/Daily6_PostgreSQL_DaviCAL.sql
mv /network/backups/Database_Backup/Daily4_PostgreSQL_DaviCAL.sql /network/backups/Database_Backup/Daily5_PostgreSQL_DaviCAL.sql
mv /network/backups/Database_Backup/Daily3_PostgreSQL_DaviCAL.sql /network/backups/Database_Backup/Daily4_PostgreSQL_DaviCAL.sql
mv /network/backups/Database_Backup/Daily2_PostgreSQL_DaviCAL.sql /network/backups/Database_Backup/Daily3_PostgreSQL_DaviCAL.sql
mv /network/backups/Database_Backup/Daily1_PostgreSQL_DaviCAL.sql /network/backups/Database_Backup/Daily2_PostgreSQL_DaviCAL.sql
mv /network/backups/Database_Backup/Daily_PostgreSQL_DaviCAL.sql /network/backups/Database_Backup/Daily1_PostgreSQL_DaviCAL.sql
su postgres -c 'pg_dump davical' > /network/backups/Database_Backup/Daily_PostgreSQL_DaviCAL.sql
#################################################################################################
Friday, 7 August 2009
Adding an Axiz PTZ camera to ZoneMinder
I added a Axis 213 PTZ dome camera to our ZoneMinder server using the following settings (After turning on PTZ in the Options->System tab (ZM_OPT_CONTROL), and restarting ZoneMinder):
General Tab:
- Source type: remote
- FPS: 6.00 (keep this high or you will get a delay in the image)
- Remote host name: xxx.xxx.xxx.xxx
- Remote host port: 80
- Remote host path: /axis-cgi/mjpg/video.cgi?resolution=CIF
- 24 bit colour
- Capture width: 384
- Capture Height: 288
- Control Type: Axis API v2
- Control Device:
- Control Address: xxx.xxx.xxx.xxx:80 (mind the ':' and the port number !!)
- sudo apt-get install libmodule-load-perl
Friday, 24 April 2009
Weird Time Machine errors on Leopard Server
I looked through the logs and found this: (note that most backups finish ok, just some with the error below)
4/24/09 9:38:15 AM /System/Library/CoreServices/backupd[64124] Starting standard backup
4/24/09 9:38:15 AM /System/Library/CoreServices/backupd[64124] Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
4/24/09 9:38:17 AM /System/Library/CoreServices/backupd[64124] No pre-backup thinning needed: 131.4 MB requested (including padding), 187.56 GB available
4/24/09 9:38:21 AM /System/Library/CoreServices/backupd[64124] Stopping backup.
4/24/09 9:38:21 AM /System/Library/CoreServices/backupd[64124] Error: (-43) SrcErr:NO Copying /private/var/imap/user/a to /Volumes/Time Machine Backups/Backups.backupdb/Saturn/2009-04-24-093816.inProgress/83D4516C-94ED-4201-9F20-9547F53209EF/Leopard Server/private/var/imap/user
4/24/09 9:38:21 AM /System/Library/CoreServices/backupd[64124] Copied 4 files (10.7 MB) from volume Leopard Server.
4/24/09 9:38:21 AM /System/Library/CoreServices/backupd[64124] Copy stage failed with error:11
4/24/09 9:38:27 AM /System/Library/CoreServices/backupd[64124] Backup failed with error: 11
I always thought that Time Machine does not backup mail stuff, but it apparently does backup parts (useless parts) of the IMAP mail store.
The fix I'm trying is to add the /var/imap/users/ dir to the exclude list in the Time Machine preferences screen. See if this helps....
Thursday, 16 April 2009
Rebuilding a Zoneminder system after a Crash
This time we installed a 160GB disk for the system itself and swap, and a seperate 500GB disk for events and backups of the system.
The start of the guide still applies, but we also did the following:
using fdisk created a 6GB for backups and a 482GB partition for events
Formated both as EXT3 and added the following to /etc/fstab:
/dev/sda1 /backups ext3 defaults,errors=remount-ro 0 1
/dev/sda2 /var/cache/zoneminder/events ext3 defaults,errors=remount-ro 0 1
Set correct permissions for the events dir:
sudo chown www-data:www-data /var/cache/zoneminder/events/
Added a time sync script:
sudo nano /etc/cron.daily/timesync
And added:
#!/bin/sh
ntpdate 0.nl.pool.ntp.org
Then:
sudo chmod 755 /etc/cron.daily/timesync
Fix Video permissions:
chmod 4755 /usr/bin/zmfix
Added a MySQL backup script I also use on our main Linux server:
sudo nano /etc/cron.daily/DB_backup
Added:
#!/bin/sh
mv /backups/MySQL_Backup/Daily6.sql /backups/MySQL_Backup/Daily7.sql
mv /backups/MySQL_Backup/Daily5.sql /backups/MySQL_Backup/Daily6.sql
mv /backups/MySQL_Backup/Daily4.sql /backups/MySQL_Backup/Daily5.sql
mv /backups/MySQL_Backup/Daily3.sql /backups/MySQL_Backup/Daily4.sql
mv /backups/MySQL_Backup/Daily2.sql /backups/MySQL_Backup/Daily3.sql
mv /backups/MySQL_Backup/Daily1.sql /backups/MySQL_Backup/Daily2.sql
mv /backups/MySQL_Backup/Daily.sql /backups/MySQL_Backup/Daily1.sql
mysqldump -r /backups/MySQL_Backup/Daily.sql --all-databases
Then ran:
sudo chmod 755 /etc/cron.daily/DB_backup
sudo mkdir /backups/MySQL_Backup
Set up main backup system using Rsnapshot:
sudo apt-get install rsnapshot
sudo nano /etc/rsnapshot.conf (Watch for tabs instead of spaces!!!)
Contents of config file: (used cat /etc/rsnapshot.conf | grep -v -e ^# to get this output btw)
(ALL SPACES MUST BE TABS!!)
config_version 1.2
snapshot_root /backups/
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
interval hourly 6
interval daily 7
interval weekly 4
interval monthly 6
verbose 2
loglevel 3
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
rsync_short_args -a
rsync_long_args --delete --numeric-ids --relative --delete-excluded
exclude /backups
exclude /dev
exclude /media
exclude /proc
exclude /tmp
exclude /mnt
exclude /sys
exclude /proc
exclude /var/cache/zoneminder/events
backup / localhost/
Then add this to /etc/crontab:
0 */4 * * * root /usr/bin/rsnapshot hourly
50 23 * * * root /usr/bin/rsnapshot daily
40 23 1,8,15,22 * * root /usr/bin/rsnapshot weekly
30 23 1 * * root /usr/bin/rsnapshot monthly
Installed X and setup autologin and auto script run:
sudo apt-get install gdm
sudo apt-get install xorg
On the machine itself (not SSH) ran:
sudo startx
sudo gdmsetup
In gdmsetup I set the user 'zoneminder' as autologin, and set the default session to run the Xclient script.
Create the Xscript:
nano /home/zoneminder/.xsession
And insert:
#!/bin/sh
while ( true )
do
/usr/sbin/xlib_shm-script
sleep 1
done
Then run:
chmod 755 /home/zoneminder/.xsession
Set the correct screen resolution:
sudo apt-get install displayconfig-gtk
sudo displayconfig-gtk
I set this to 800x600, this suits the cameras best
Stop screen blanking by adding this to the /etc/X11/xorg.conf file:
Section "ServerFlags"
Option "blank time" "0"
Option "standby time" "0"
Option "suspend time" "0"
Option "off time" "0"
EndSection
Create, setup & install the Xlib_shm Zoneminder raw viewing script:
Check the version numbers! not all Xlib_shm version is compatible with each version of Zonderminder!
sudo wget http://dig.hopto.org/xlib_shm/xlib_shm-0.6.3.tgz
sudo tar xfz xlib_shm-0.6.3.tgz
sudo apt-get install libxv-dev
sudo apt-get install build-essentials
sudo apt-get install libmysqlclient15-dev
sudo nano xlib_shm.c
And changed /usr/local/etc/zm.conf into /etc/zm/zm.conf
sudo make all
Place the binary xlib_shm in /usr/sbin/
sudo chown root.root /usr/sbin/xlib_shm
sudo chmod +s /usr/sbin/xlib_shm
For the actual auto starting of xlib_shm I first created a new shell script:
sudo nano /usr/sbin/xlib_shm-script
And added this:
#!/bin/sh
xlib_shm -m 1 -m 23 -m 11 -m 12 -k 0x07a6d0000 -d 40000
Then:
sudo chmod 755 /usr/sbin/xlib_shm-script
Monday, 9 March 2009
Automated mailbackup with Mailbfr
I made a new script:
sudo nano /etc/periodic/daily/710.mailbfr
Added this:
#!/bin/sh
mailbfr -b /Volumes/Backups -mo full
Seems to work!
Friday, 27 February 2009
Setting up rsnapshot backup tool on Linux + NFS
Hint:
I'm always struggling to get NFS going for some reason, using the command showmount -e
you will get a list of the NFS server's shares. That helps a lot!I set up a seperate partition on the Mac server as an NFS share only to be accessed by one IP address, that is the IP of the Linux server.
The Linux server has an hourly cronjob to keep the NFS mounted, just to be sure. I placed this file in /etc/cron.hourly/MountNFS-Share Contents:
#!/bin/sh
mount 192.168.0.3:/Volumes/Jupiter-Backups /mnt/backup/
Next I added this following to /etc/crontab on the Linux server:
0 4 * * * root /usr/bin/rsnapshot hourly
50 23 * * * root /usr/bin/rsnapshot daily
40 23 1,8,15,22 * * root /usr/bin/rsnapshot weekly
30 23 1 * * root /usr/bin/rsnapshot monthly
This way the Linux server should backup itself incrementally to the Mac server's RAID device. Also, because the backup goes to the RAID device it will automaticaly be an extra off-site backup.