Ubuntu: Using compression on your tape backups

  If you have compressible data you may save space on you tapes by using compression; this comes at a cost of CPU cycles to do the compressing, which can often be a worthwhile tradeoff for a long-term backup. To do this is quite simple – add in the -z switch to your tar command.  
tar -cvzf /dev/[tape-device] [folder or files to back up]
tar -cvzf /dev/st0 /opt/movies
  For some file types – e.g. movies, mp3s, compressed picture files and the like you probably won’t see a great deal of space saved – though if it enough to save you from using two tapes instead of one, it may be worth it even so. Text and other file types may compress more easily and you may see more of a savings – it will vary greatly depending on your dataset. Try it and see!   Sometimes you may see people using the -j switch instead – this uses the bzip2 algorithm rather than the gzip algorithm (the -z switch). You will probably find that gzip is slightly better supported and bzip2 sometimes provides slightly better compression but takes longer. If you are chasing better compression it may be worth replacing the z switch with j to see if it helps.

Ubuntu: Using tar to span a backup across multiple tapes

  Following on from the article on writing files to a tape backup, what happens if you want to back up more than what fits on a single tape? Here we want to use the –multi-volume switch, or -M. Use it so:  
tar -cvMf /dev/[path-to-tape] [backup folder or files]
  As a working example:  
tar -cvMf /dev/st0 /opt/movies
  Once the first tape is full, tar will prompt you to insert another:  
Prepare volume #2 for `/dev/st0′ and hit return:
  Make sure you replace the tape with another before hitting return or else it will over-write the just-finished tape!   With the exception of a file which sits across multiple tapes (think of a file which starts at the end of one tapes and finishes at the start of the next) you don’t need a first tape to restore the files on the second. You also cannot use compression for multi-volume archives.

Mediawiki 403 forbidden errors after upgrading to Ubuntu 13.10

  A customer upgraded from 13.04 to 13.10 and their internal wiki was broken afterwards; for a simple Apache install where the wiki was installed at the web root and all access was via the LAN (thus they were happy with not restricting the access), the fix was to add:  
<Location /> Require all granted </Location>
  towards the bottom of:  
…just above the last line, which should be </VirtualHost>. Restart apache with:  
service apache2 restart
  After that you should be able to refresh and see your wiki as before.

ZFS on Linux (Ubuntu) – arcstat.py is now available! How do you run it?

UPDATE: This information is now out of date, see new post here.   One very handy ZFS-related command which has been missing from the standard ZFS on Linux implementation has been arcstat.py. This script provides a great deal of useful information about how effective your adaptive read cache (ARC) is.   ZFSoL 0.6.2 includes it, which you can now update to in Ubuntu with apt-get upgrade. But how do you actually use it when you upgrade? Easy. Assuming you have python installed, run the following (this works for 13.04 at least – we will check the others and update when we do):  
  This will provide you with the default readout, e.g. for our system which just rebooted:  
    time  read  miss  miss%  dmis  dm%  pmis  pm%  mmis  mm%  arcsz     c 21:33:13     3     1         33          1       33        0        0           1        33       2.5G   15G
  As you can see, since the system has just rebooted and hasn’t started caching requests the ARC size is quite small – 2.5G. This is an extremely useful tool to get an idea of how your ARC is performing – we will do a piece on interpreting the results soon!

Ubuntu: How to check the samba version

  To check the version of Samba that you are running, use the smbstatus command. The first line is the version, which should look something like:  
Samba version 3.6.3
  If you want to see just the version without the rest of the smbstatus information, you can run:  
smbstatus –version
  Much less cluttered. The above is the current version for a 12.04 Ubuntu server. Still waiting for version 4!

Where is the crontab in Ubuntu?

  If you’re looking to make a copy of a user’s crontab as a backup or just to view it without using the crontab editor, you can locate it at:  
  Each user’s crontab will be in this directory in a file named as their username (e.g. root). If you’re working with a lengthy crontab it’s a good idea to back it up – can save you a lot of work if everything goes pear-shaped.

Ubuntu: How to restore your files from a tape

  This is just like extracting a regular tar archive:  
tar -xvf /dev/[path to tape] [directory or file to restore]  
tar -xvf /dev/st0 backups
  This will restore the “backups” file/folder to the current working directory. To check your current directory, you can use:  
  to make sure that you are restoring your files to the correct location!

Ubuntu: How to write files to a tape

  To put files onto a tape, run the following:  
tar -cvf /dev/[path to tape] [file or directory] [file or directory] [file or directory]
  An example would be:  
tar -cvf /dev/st0 /home/bob
  This will back up the user bob’s home directory to the tape, here located at /dev/st0 (a typical location – note the zero, not the letter o).   If you want to use compression in your backup, use the z flag in addition to the other tar flags, such as:  
tar -cvfz /dev/st0 /home/bob
  All done!