Creating system backups with zip

Zip isn’t the only mechanism available on BeOS for creating system backups (a much more user-friendly, complete backup system for BeOS is Bald Mountain’s BeB), but it does have some pretty powerful capabilities… once you get to know the command-line options.
If you’re using BeOS R4.1 or later, zip should already be installed on your system. The latest version can always be download from BeBits.

General backup notes

Since backups can take a while, plan things out before beginning so you don’t have to run the same backup a bunch of times to get it right. For example, you may want to just back up your home directory, skipping the rest of the system, on the assumption that you can always install the OS and apps easily enough later down the road. You also may want to create certain archives based on system queries. Or you may want to back up everything but image and sound files. You may or may not want your backups to follow symlinks.
It helps a lot to have multiple BFS partitions, if you can afford the space. It’s useful, for instance, to have a partition dedicated to media files, where you can store all of your images, movies, and sounds. You can create links to these directories on other partitions inside your home folder for easy access.
Of course, it goes without saying that a backup is worthless if you don’t move it to another physical hard drive. Better yet, move it to another machine, to your web server, or to a removeable cartridge that you can store off- premises, in case of fire or flood.

Basic syntax

The basic zip syntax is zip outfile infile, where infile is typicall a directory name. The .zip extension will be automatically added to the end of outfile. Thus, if your current directory is /boot/home and you want to back up your /boot/home/words directory, you might type:

zip words words

This would create a file called words.zip in /boot/home that would include the contents of /boot/home/words.

Recurse sudirectories

Of course, you’ll usually want your zips to crawl through entire subdirectory structures. Thus, you’ll need the -r flag, for „recurse,“ e.g.

zip -r /boot/home/mail_backup /boot/home/mail

This will crawl your entire mail folder and all of its subdirectories. Unzipping the archive later will recreate this directory structure.

Skip some filenames

You may feel that some files are too huge to be backed up, and/or they’re not important enough to be worth the space. Tell zip to skip them with the -x flag. E.g.:

zip -r some_images images -x "*tga" "*tif*"

would crawl the images subdirectory of the current directory and zip everything except for files ending in „tga“ or including „tif“ in their names.

Note the quote signs around the name templates – without them zip would ignore just those targas and tiffs which are in the current directory.

Thus, you could back up all of your gifs and jpegs but skip your larger targas and tiffs. You may also want to skip some common sound file extensions, or other .zip files this way.

Include only some filenames

The opposite of the -x flag is the -i flag, which will cause zip to only zip the files you specify. So, for instance, if you want to back up the mirror of your web site but only archive HTML files and none of your images, you could use:

zip -r site_backup /boot/home/mysite -i "*html"

Dereference symlinks

If you’ve been using symlinks liberally, you could run into problems if you allow zip to follow them — you could end up zipping much more than you intended. To store symlinks without following them, use the -y flag:

zip -yr image_bak images

This command will back up your entire images directory, but won’t follow any symlinks it finds within. E.g. you may be storing all your targas on another partition and accessing them via symlink in your images directory — decompressing this archive will give you a live working symlink, but won’t back up the remote directory itself.

Achieve maximum compression

If you want to make sure your zip archive ends up as small as possible, use the -9 flag to specify maximum compression. This will cause zip to operate a little more slowly, but machines today are fast; it’s usually worth it. Thus, a good, straightforward set of backup flags to use is:

zip -9ry outfile infiles

Have zip take the output of another command

It’s possible to pipe the output of a shell command into the input of zip by using the -@ flag. For example:

ls | zip testfile -@

would simply run an ls on the current directory and zip all the files in that list. But wait — this actually gets useful, because you can just as easily run a query or find command to find only files that match a given criteria and make an archive of them alone (see the tip Queries from Terminal if necessary).
Thus, the following command zips up just your BeMail messages with a status of „Sent“ that were last modified before August 1. You’ll have to unwrap this all onto one line:

query "(((MAIL:status=="*[sS][eE][nN][tT]*")&&
(last_modified<=901954800))&&
(BEOS:TYPE=="text/x-email"))" |
zip -r /boot/home/outgoing.mail.pre.080198.zip -@

Update an existing archive

One flag specially geared toward creating backups is the -u flag, which is used to „update“ an archive with only the files that are new or that have been changed since the archive was last created or updated. This is your equivalent of the „incremental backup.“ In the example above, we used < tt>ls | zip testfile -@ to create a simple archive called testfile.zip of all files in the current directory. Now let’s say you edited one file in this directory and created one new one. If you now run:

ls | zip -u testfile -@

then zip will add the new file to testfile.zip and update the file you edited. Note that this assumes that testfile.zip already exists.

Add a comment to your archive

If you want to include a note to yourself inside the archive, use the -z flag. For example, you may not look at this archive again for a year, and want to be reminded at that time that this zip did not include any targa images. Type:

zip -r -z image_bak images -x "*tga"

After compression is complete, the shell will prompt you to enter your message — it can be as long as you like. When finished, type a period on a blank line. Double-click the file and Expander will show your comment as the first line. Similarly, unzippng from Terminal will display the comment as the first line in the shell output (Expander is just a window onto shell output).

Grow an archive

To add files to an existing archive, use the -u flag (for update) to add any files that have changed or that are new. To add only files that have changed but skip new files, use the -f flag (for freshen).

Unzip options

You’ll also want to become familiar with the unzipping options, so you can restore your archives properly, without overwriting data. You can see all of the unzip options with unzip --help, but the most important are:
Test the integrity of an archive: unzip -t filename.zip
Just show the comment embedded in an archive: unzip -z filename.zip
Exclude some files: unzip -x "*tga" "*mp3" (this would extract everything but mpeg sounds and targa images).
Include only certain files: unzip -C filename.zip *html* (This will extract only files that have „html“ in their filenames; note that the wildcard characters are escaped so as to not confuse the shell).

More info

Both zip and unzip have many more options, accessible via zip --help< /tt> and unzip --help.

 

Noisy but working AWE64

Well, I just bought myself an AWE64, and guess what. That AMPLIFIED OUTPUT is making NOISE in BeOS, but not in Win95 (not because MS is better, they just don’t know how to 🙂 ). So I decided to fix it.
The reason for the noise is that the Be guys love it loud and therefore they crank up the output gain to 4x. Now with the amplified output (at least my amplified output) it makes A LOT of noise which I don’t enjoy. Since there is no ’normal‘ way of getting it down to 1x I decided to tell you how to fix it. It’s not perfect, but hey don’t blame me I didn’t cause it. In fact don’t blame me if you don’t know what you’re doing and something goes wrong. I take no responsability for this ‚hack‘ and what happens to your system.
What this ‚hack‘ does:
What it does is simply write to the soundcards mixer register and turn it down to 1x. It’s only four basic operations so I decided to write a script since this code should have been in the driver anyway. Here it is.
Solution:
This assumes that your awe64 is installed (and working!!!) at 0x220. (You can check this with the Devices preferences panel). If it’s installed in another way you take the two first numbers (in this case 22) and replace the 22’s later in this example.

1. In your ‚UserBootscript‘-file located in ‚/boot/home/config/boot‘ add the following line first:
poke &#60;/boot/home/CorrectSound >/dev/null

2. Use an texteditor (StyledEdit maybe) and write the following:
outb 0x224 0x41 outb 0x225 0x0 outb 0x224 0x42 outb 0x225 0x0 quit

3. Save the texteditor file to /boot/home/CorrectSound

4. Open a Terminal and type: poke &lt;/boot/home/CorrectSound

It’s done. And once you restart you will have about 2 seconds of noise at start-up (I told you it wasn’t perfect). Now, start sending me money :).

 

NetPositive: Use a different e-mail client

By default, clicking an e-mail link from within NetPositive will launch a new BeMail message. If you’re using Mail-It, Adam, or another BeOS e-mail client, this may not be the behavior you want. NetPositive, however, does not include an option in its preferences to change the default mail client.
There’s a good reason for that — what you actually want to do is to change the default mail association system-wide, rather than for NetPositive alone. You could do this via the FileTypes preferences panel, but you’ll probably find it easier to right-click on any BeMail message, choose Open With… from the context menu, and release there rather than choosing another app to open that particular message with.
In the yellow-backed dialog that ensues, select the mail client you want and click „Open and make preferred.“ Your system-wide mail client association will be changed permanently (or until you change it back again).


Here’s a slightly different approach to the same basic situation. These instructions provided by BeatWare:

Making Mail-It the Default Mail Program

You can make Mail-It the default email package (i.e. the one that is started automatically from other programs such as NetPositive) by following these simple instructions:
1. Launch Mail-It. This lets the BeOS know that the application exists.
2. Close Mail-It.
3. Open the FileTypes application, which is available from the
Preferences folder (you can also find the Preferences folder in the
Tracker menu).
4. Select and expand the „text“ field from the list of file types located
just below the File menu.
5. Select „E-mail“ from the list of items listed under „text.“
6. Under „Preferred Application:“ select „Mail-It“ in the drop-down list.
7. Close the FileTypes window.

 

Gobe Productive: Quickly access extra functions

You can quickly access extra functions in Gobe’s Productive by using the Control and Command keys (PC users: Right-Ctrl and Alt) — or by right-clicking — to pop up a menu of extra functions related to the currently selected object.
For example, launch Productive and open a graphics window, then draw a polygon. With the polygon still highlighted, press the Control and Command (Alt) keys and click inside the polygon with the mouse. A pop-up menu consisting of Lock, Arrange, Pen Size, Closed, Smooth, Unsmoothed, Auto-Smooth, and Add to Tool Bar appears. These functions are the same as those in Window headbar, only this way the important features are there in the object you’re creating.
Quickly accessing functions this way is available in the Graphics, Word Processing, Spreadsheet, and Presentation modules. I’m sure that as the image processing capability grows, we’ll see it there too. Experiment with different modules and see the power of Productive for yourself.

 

Screenshots of screensavers

Want to take screenshots of your BeOS screensavers in action? The act of hitting PrintScreen disables the screensaver, making this impossible, but there’s a workaround:
Download a copy of Chris Herborth’s Grab and install it in ~/config/bin. Launch the ScreenSavers preferences panel and select the saver you want to shoot.
Now open a Terminal and type:

sleep 5; grab -o ~/saver.tga 

replacing 5 with the number of seconds you want to wait and using the actual path and filename you want output. Minimize the Terminal window and press the Test button in the ScreenSavers panel.

 

Fixing corrupted font display

In very rare instances, BeOS‘ font settings can become corrupted. You’ll know this has happened to you if you boot up and all you see are little boxes where your letters should be. To fix this problem, you’ll need to delete two files:

/boot/home/config/settings/fonts_list
/boot/home/config/settings/fonts_status

and then reboot. If you can’t see your way around clearly enough to do this, you can either telnet in from another box (if you’re on a network and have the telnet server running), or you can boot with the boot floppy and installation CD inserted, then launch Terminal with [left] Ctrl+Alt+Shift+T.

 

Make MP3 playlists automatically

Lets say you have all your mp3’s in /musik/mp3/ (all end with MP3). There are subdirectories in this directory and everything and you want to make a playlist of all of them and place it in /boot/ home/Desktop/playlists/.
There is already another playlist which you made directly with Soundplay (or CL-Amp) in that directory which is named sample. But in /musik/mp3/ there are a lot of mp3’s and you really don’t want to add them all by hand.
Then you just have to open a Terminal and type cd Desktop/playlists and
then:

find /musik/mp3/ -name *MP3 -print &gt; allmp3s
copyattr sample allmp3s

There you go. You will have a working playlist of all the mp3’s in the directory. Be sure and use the full absolute path to your MP3 directory, or you may end up with relative paths in your playlists (which won’t work).
You could also do the find differently and only put the files that have jazz in their name in a playlist. So if you named all your jazz files jazz_someone.MP3 then you would use:

find /musik/mp3/ -name jazz*MP3 -print &gt; jazz
copyattr allmp3s jazz

You can of course also change the directory and only put the files from /musik/mp3/rock in the playlist by typing:

find /musik/mp3/rock/ -name *MP3 -print &gt; rock
copyattr allmp3s rock

I think you got the general idea. Just make sure that you made one playlist with Soundplay so you get the attributes right with copyattr and remember that the searches are case sensitive.

 

Installing GeekGadgets

The enormous GeekGadgets collection includes a ton of BeOS ports of common Unix tools. Unfortunately, these tools assume you know how to bootstrap yourself — the Amiga-centric documentation they come with won’t give you the slightest clue how to get them running on BeOS. Here’s a crash course:
1) Create a GeekGadgets subdirectory in /boot/apps
2) Save the code below as a text file, located at
/boot/apps/GeekGadgets/etc/gg-startup.sh

export GG=/boot/apps/GeekGadgets
export PATH=$GG/bin:$GG/X11R6.3/bin:$PATH
export LIBRARY_PATH=$GG/X11R6.3/lib:$LIBRARY_PATH
export C_INCLUDE_PATH=$GG/include
export SHELL=$GG/bin/bash
export CONFIG_SHELL=$GG/bin/bash
export BELIBRARIES=$BELIBRARIES:$GG/lib

3) Open your ~/.profile or ~/config/boot/UserSetupEnvironment and add the
following line:

source /boot/apps/GeekGadgets/etc/gg-startup.sh

4) Save and close these files, then type source .profile into the shell to make the new environment variables take hold. Essentially, what you’ve done here is to create a new file containing environment variables specific to GeekGadgets, and invoked that file from .profile. By doing it this way, you decouple GG variables from the rest of your system variables, so you can remove them from your path and system memory at any time by removing the source line from .profile.
To install individual GeekGadgets programs, download them from ftp.ninemoons.com directly into /boot/apps/GeekGadgets, (or move them there after downloading to your usual location) then double-click to let Expander decompress them. It’s important that they live in this location, and that you decompress all GG tools from your GG root.
You can install as little or as much of GeekGadgets as you like. Note that you can optionally download pre-compiled versions of most GeekGadgets utils (at least you can for x86; PowerPC utils may still require manual compilation).

 

Compiling Unix utils

Ever download an archive full of code, follow the instructions to type „make“ at the command line… and get absolutely nowhere? It may be because the OS referred to in the Makefile is referencing a target OS other than BeOS, or because its referencing the wrong compiler for your platform.
Look in the same directory for a file called „Makefile.“ Open the Makefile in a text editor and look for lines near the top that look like this:

CC = gcc
OS = UNIX

These lines may not be right next to each other, but they should both be near the top somewhere. Edit them so they reference the right operating system and compiler instead:

CC = cc
OS = BEOS

On BeOS/x86, either cc or gcc should work on the compiler line. If you’re using BeOS/PowerPC, you may need to change this to
mwcc.
Save the file and run „make“ again — you should be golden.

 

Grok keymappings for Windows keyboards

If you have a 104-key Windows keyboard, you may find the documentation in the Be User’s Guide a little off the mark. While most of the mappings are the same as for 101-key keyboards, a few of them are different. Here’s an updated map:


Cross-Platform Keyboard Equivalencies and Functions


Windows PC Key Label (104 keys)


Standard PC Key Label (101 keys)


Macintosh Key Label


BeOS Key Name


BeOS Function


Alt

(either side)


Alt

(either side)


Command

(either side)


Command


Used with other keys as a shortcut to Tracker actions, and to selecting application menu shortcuts directly, but not for pulling down menus. a.k.a. the „trigger“ key.


Ctrl

(left)


Ctrl

(left)


Control


Control


Used for emacs-style keybindings in Terminal and BeMail. e.g. Left Control+C stops the running Terminal job and Left Ctrl+E jumps to the end of a line in BeMail.


Ctrl

(right)


Ctrl

(right)


Option


Option


Used to type special characters such as symbols and accented characters in supporting applications. e.g. Right Ctrl+ J in StyledEdit yields the triangular delta symbol: &#68;


Menu key


No equivalent

?

?

Used to pull down application menus. e.g. Edit menus can be accessed with Menu+E. Other keyboards must use Ctrl+Esc to activate the first menu, then arrow keys to navigate.

Left Windows key


Ctrl

(right)


Option


Option

Advanced text navigation in some apps. e.g. Win + left or right arrow moves cursor one word at a time in editors like Eddie and Pe.


Right Windows key


No equivalent

?

Unused.

Enter


Enter


Return

Enter


Used to „commit“ a typed entry or to act on a selected file, as a shortcut for clicking on-screen buttons, and opening files. Hitting Enter on a selected item is equivalent to double-clicking it.


Esc


Esc


Esc


Escape

Used as a shortcut to clicking Cancel in many panels, and to dismiss open pulldown menus.


Tab


Tab


Tab


Tab


Used to cycle through multiple fields, e.g. to move between fields in a dialog box or between links on a Web page.


(arrows)


(arrows)


(arrows)


arrows keys


Used to move the cursor in text documents, to scroll through lists and menus, and to move the cursor wherever vertical and/or horizontal
motion is required.


Shift


Shift


Shift


Shift


Used to select text in documents (in conjunction with other navigation keys), and to augment other actions, e.g. to select multiple files
in Tracker.


&nbsp;




 
 

Kategorien