I have been searching for some sort of automated backup while I wait patiently for 10.5's Time Machine. While searching, I found this article on TUAW covering one method of automating the process.
I have re-written the backup scripts from that article to make them a little friendlier. Current features include:
Supports the backing up of multiple source directories
Uses rsync to cut down on un-necessary file transfers
Designed to allow for a minimum time between backups (default 24 hours) to prevent un-necessary system interruption.
I am planning on implementing several new features when time permits, including different backup profiles for different devices (eg: full backup to this drive, but only backup my documents and keychain when my iPod is plugged in...), and network rsync support...
Full code and instructions can be found here, and comments and suggestions welcome...
[robg adds: I haven't tested this one, but since backup is a personal hot topic of mine (not enough people have working (ideally multiple) backups), I thought it worth sharing.]
The hint presents a way to generate a list of all of the Unix commands in your execution PATH (see this Unix FAQ for an explanation of the execution PATH variable) with a one-line synopsis for each program (assuming this one-line description is available). This is accomplished via a rather complicated pipeline of commands:
Here are the first several lines of output from the above command when run on my Mac:
SystemStarter - Start, stop, and restart system services
Xmark - summarize x11perf results
Xnest - a nested X server
Xquartz - X window system server for Quartz operating system
Xvfb - virtual framebuffer X server for X Version 11
a2p - Awk to Perl translator
If you want the output of the above command to be saved into a file instead of appearing in the Terminal window, add a greater-than sign and then the name of the file you want to create at the end of the command.
If you use the MacPorts and Fink package managers, you might find it useful to be able to update both package managers with one simple command. I wrote the following simple script which does just that:
#the script updates MacPorts and Fink packages;
if [ "$(whoami)" != 'root' ]; then
echo "You have no permission to run $0 as non-root user."
port -d sync
port upgrade installed
fink -q -y selfupdate
fink -q -y update-all
Just create a file containing that code and save it, say, to your home folder. Assuming that the file's been saved as ~you/updf (where you is your short username), just cd to that directory and make the code executable:
chmod u+x upfg
If it's not already set, you might also add the line PATH=$PATH:~you to your profile. Then simply type sudo upfd, wait a little bit, and you're done. Hopefully, that is, if there are no compilation errors, but that's another story!
I was trying to figure out a way to be able to access my my Safari bookmarks from anywhere, without having to dig through the plist folder over ssh (especially on a slow connection). So, I wrote a shell script to do it; it does require plcat, which is part of the free PLtools package.
[robg adds: Set the script to executable (chmod a+x script_name), and edit the script to replace **YOUR USERNAME** with, well, your user name. I tested the script, and it works -- it creates an index.html file in whichever directory you run it in. You can then edit or view the index.html file using any text editor, such as vi.]
I always wanted to use the ffmpeg command line tool (the one ffmpegX is the GUI of) in Terminal, but I didn't find it in Fink, and I didn't want to compile it from an experimental source. Well, there is a working binary of ffmpeg bundled with ffmpegX. To get it, simply follow these steps:
Get ffmpegX from the above URL. It's a pretty useful tool, because the ffmpeg synatx isn't quite easy to handle.
Control-click on the ffmpegX application, choose Show Package Contents from the pop-up menu, and navigate into Resources.
When you get an attachment in Mail, the usual way to move it to a folder is via the Save button in the message or a control-click and then choose Save (or you can drag it into a Finder window). Either of these methods brings up a Finder window from which you can mouse around to put it where you want.
But if you are already working in a Terminal window in the directory where you want to save the attachment, type 'cp ' (note the space), then drag the attachment to the Terminal window and drop it there. Finally, type a period. When you're done, your Terminal window will look something like this:
I created this simple bash script to perform periodic maintenance. I put the script file in my ~/bin directory, and I added the folliwing line to my .profile file (where my_user is my short username):
Now, when I want to perform maintenance, I open a Terminal window and type maint at the prompt.
[robg adds: Remember to chmod 655 ~/bin/maint to make the code executable. We've had a numberofhints here over the years dealing with the periodic maintenance scripts. There are also numerous utility apps that will do this for you as well.]
If you're a web or FileMaker developer and need access to MySQL databases via ODBC, you probably know that there are no binary distributions of MyODBC drivers that work on an Intel Mac. The PowerPC version won't work, and just trying to compile from source won't either.
After discussions with others, we've succeeded in compiling myODBC and it works! The trick is that you need to make simple changes in three files. Change the references to odbcinst.h to iodbcinst.h in these files: util/MYODBCUtil.h, driver/myodbc3.h, and myodbcinst/myodbcinst.c.
[robg adds: Apparently this information is in a README.osx in the distribution, but many haven't found that (judging by the results of a quick net search). This thread on the macosxhints' forums also covers the problem; if you need more detail on the process, check either link.]
This is a warning as well as a hint. Control-clicking on a file or folder brings up a contextual menu that includes the option to Create archive of "xxx". The created archive file is a zip file that can be unzipped with /usr/bin/unzip. So, one would think that OS X is using /usr/bin/zip to create the archive. But that isn't so. It seems that OS X creates the zip file using code internal to Finder. It seems (from output of ps or top) not to be using /usr/bin/zip. Now the warning: /usr/bin/zip is broken on HFS+ file systems. It is broken in two ways:
By default, it does not preserve the resource fork of files that it archives.There seems to be no way to force it to preserve resource forks. (Has anyone found a way?)
Its behaviour does not correspond to its man page: /usr/share/man/man1/zip.1
Those (like me) who want to automate backups of their system using command line tools should perhaps use /usr/bin/tar. The tar utility now (as of OS X 10.4.8 and perhaps earlier) preserves resource forks. It stores the resource fork of foo as ._foo, and then recombines the data and resource forks when untarring to an HFS+ volume. To archive and compress a folder foo and all of its subfolders, one can do: