19 March 2007

restore emailaccounts from backup in directadmin

We mirror our production servers with rsync. So on our backupserver we have a copy of the complete filesystem of our production servers.

To restore all emailaccounts of a direactadmin user the following directories have to be copied back from the backup- to the production server:

/etc/virtual/domainname.com/
/var/spool/virtual/domainname.com/
/home/username/mail/
/home/username/imap/
/home/username/.spamassassin/


To copy the files back to the productionservers we use the following rsync command

rsync -avzI --numeric-ids --ignore-errors --force local/path/ user@production.server.com:/remote/path

05 March 2007

Speedup Mac OS X Mail.app


  1. Quit Mail & go to Terminal.

  2. Issue the following commands:
    cd ~/Library/Mail
    sqlite3 Envelope\ Index

  3. You will be dropped in an sqlite> prompt.

  4. Now issue the command vacuum subjects; (this will do something like OPTIMIZE TABLES in MySQL).

  5. Hit Ctrl-D to exit SQLite, exit Terminal and start Mail again

22 February 2007

Automatic backup on Mac OS X using rsync

I want to backup my iTunes music library and my iPhoto library to our local backup server that I'm able to SSH login to ...

  1. First off, enable passwordless login to the remote server. We generate a public/private rsa key pair using ssh-keygen -t rsa. Do not enter a passphrase so that it won't ask for one later :) Now copy the contents of the generated .pub file (your public key) to your server in the file ~/.ssh/authorized_keys. You should be able to login to your server using ssh username@server now.

  2. Create a script that rsyncs your libraries that contains
    rsync -a -e ssh "/Users/local_username/Music/iTunes" username@server:remote_path --update
    rsync -a -e ssh "/Users/local_username/Pictures/iPhoto Library" username@server:remote_path --update
    and name it, for instance, backupLibraries.command in your ~ folder. You can test it from the command line, now, if you so desire: ~/backupLibraries.command.

  3. The easiest way to make sure that your script is executed daily, automatically, is by using an iCal event (pffff...). First, we'll create the AppleScript that will be executed by iCal. Open Script Editor (Applications:AppleScript:Script Editor) and create a script that contains
    do shell script "/bin/bash /Users/local_username/backupLibraries.command > ~/rSyncErr.txt || echo -n"
    You can try this by pressing 'Run' from Script Editor. Store the script as backup.scpt, for instance.

  4. Now create an iCal event that executes the script daily, by setting Repeat: every day, Alarm: Run script, backup (select Other... and select the file that you just created from Script Editor), and 1 minutes after.

  5. There, you should be all set now! If something goes wrong, you will be able to find out by taking a closer look at ~/rSyncErr.txt. If you're the optimistic type, just remove "> ~/rSyncErr.txt" from the AppleScript.

20 February 2007

Director: Finding the drive letter of a Windows CD-ROM

If you are creating Director Projectors which need to access data on the cd-rom drive the projector is distributed on you need to know the drive letter of the cd-rom drive.

Macromedia (now Adobe) gives us a nice solution in TN 3123 (google cache). This solution uses the fileIo Xtra to try open a uniquely named file on all of the drives. Since you provided the cd-rom, with the uniquely named file, you know that the drive which has this file is the drive you are looking for. The problem with this solution is: it doesn't work within a projector!

A much better way of finding the drive letter of the cd-rom drive the projector is currently running from is using the Lingo function the moviePath.
the moviePath contains the path of the directory the movie is current;y running out of, or in our case the cd-rom drive letter!

Example:
To build a path to a directory called "PDF" on the cd-rom, you'll only need the following Lingo:
set pdfPath = the moviePath & "PDF"

19 February 2007

Detachable sessions with screen

With a detachable session you can start programs on a remote machine (via ssh for example), close the connection to the remote machine and still have your remote programs running and reachable.
The 'screen' application provides this functionality. You can start a teminal session via screen, drop the connection and reconnect to the session again, at a later point in time. This is usfull when doing remote administration over an un reliable connection.

Installing screen on FreeBSD isn't hard:
First make sure you'v installed and updated the entire ports tree.
# cd /usr/ports/misc/screen
# make
# make install


Using screen isn't hard too:
Starting a session:
screen -S <name of this session>

Detach from within a session, but keep the session running:
[ctrl]-a d

Reattach to a session:
screen -r <name of the session> (if there's only one session running, the name is optional)

18 February 2007

Enabling "disk free" report in Apache mod_dav

Apply this patch to Apache (use patch < dav-diskfree.patch in the sources directory) and install with mod_dav.

In FreeBSD, add the file to files/ in /usr/ports/www/apache22 and rename to patch-modules_dav_fs_repos.c.

Now, Apache properly reports back disk space still free when using WebDAV.

17 February 2007

Turn off the creation of .DS_Store files on network shares ...

... so that my colleagues won't be bothered with my Finder settings :)

See http://docs.info.apple.com/article.html?artnum=301711 and we know that
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
does the trick. Pfew :)

Adding AFP support to FreeBSD

Since we use both Mac OS X, Windows and Linux/FreeBSD in RedAnt, we need to configure our NAS to serve our files using AFP (Apple's way of networking). I use http://netatalk.sourceforge.net/2.0/htmldocs/ for reference ...

cd /usr/ports/net/netatalk
make
make install

cd /usr/local/etc

Edit atalkd.conf and add your network interface on one single line (sis0 in our case)
Edit AppleVolumes.default and add directories to be AFP shares

(For AppleVolumes, see http://netatalk.sourceforge.net/2.0/htmldocs/AppleVolumes.default.5.html)

16 February 2007

Adding support for Netcell NC3000 card to FreeBSD

On the FreeBSD CVS repository, in /src/sys/dev/ata (http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/dev/ata/), there seems to have been added support for NC3000/5000 chipsets.

We can confirm that sysinstall still gives a warning message regarding geometry, but it works anyway!

@ 2007-02-11 23:46:45 UTC:

Modified files: (Branch: RELENG_6)
sys/dev/ata ata-chipset.c ata-pci.c ata-pci.h
Log:
MFC: Add support for the NetCell NC3000/5000 series SATA RAID cards.

Reviewed by: sos
Approved by: imp (mentor)

Revision Changes Path
1.126.2.16 +45 -0 src/sys/dev/ata/ata-chipset.c
1.105.2.5 +4 -0 src/sys/dev/ata/ata-pci.c
1.49.2.11 +4 -0 src/sys/dev/ata/ata-pci.h

Documented @ 2007-02-12 05:37:55 UTC:

Modified files: (Branch: RELENG_6)
share/man/man4 ata.4
Log:
MFC: rev. 1.71 + part of 1.69

- Document NetCell NC3000 and NC5000 support.
- New supported ALI and ServerWorks chipsets.

Revision Changes Path
1.52.2.10 +5 -3 src/share/man/man4/ata.4

Set a static IP/DHCP in FreeBSD

In /etc/rc.conf, change
ifconfig_<network_adapter>="DHCP"
to
ifconfig_<network_adapter>="inet xxx.xxx.xxx.xxx netmask 255.255.255.0"
where xxx.xxx.xxx.xxx is the static IP address to use, and <network_adapter> your network adapter (doh!), e.g. eth0.

Don't forget to add a line like
defaultrouter="10.0.0.1"
to the same file ...