How To:Backup to Virtual Tapes on a non-UNIX Filesystem: Difference between revisions

From wiki.zmanda.com
Jump to navigation Jump to search
(Storing vtapes on Samba shares and CIFS which may not have symbolic links)
Line 3: Line 3:
== Introduction ==
== Introduction ==


Amanda has the ability to use a harddisk to store the contents of backups onto virtual tapes (vtapes) using the [[file driver]].  The vtapes can be located on any filesystem, even a remote one. Here we are using CIFS to store out vtapes on a Windows machine. This is not specific to Windows, many [http://en.wikipedia.org/wiki/Network-attached_storage NAS] devices support CIFS. The example here is a W2K machine (tapeserver) to store the tapes and a RedHat Enterprise Linux 4 machine running Amanda.
Amanda has the ability to use a harddisk to store the contents of backups onto virtual tapes (vtapes) using the [[file driver]].  The vtapes can be located on any filesystem, even a remote one.


== Setup ==
If you are following the instructions under '''Using chg-disk''' in [[How To:Set Up Virtual Tapes]] and get to the point where you run
  $ ln -s slot1 data
and get
  ln: creating symbolic link `data': Operation not supported
you likely are trying to put your virtual tapes (vtapes) on a file system that does not support symbolic links.  Unlike the chg-multi changer script, chg-disk uses a symbolic link to point to the currently active slot of your virtual tape changer.  If you can't create the link above, neither can Amanda.


The setup of Amanda is covered in the article, "[[How To:Set Up Virtual Tapes]]." there are only a couple of extra steps to perform. We choose a setup with '''''chg-disk'''''.
A common example of this is using CIFS to store our vtapes on a Windows machine. This is not specific to Windows, many [http://en.wikipedia.org/wiki/Network-attached_storage NAS] devices support CIFS.


Firstly, you need to create some vtapes on your CIFS device. Where possible it is probably best to keep them all under a single directory, with the config name inside it. For example if your config name is Daily, you might create several directories called slot1 to slotN in D:\AmandaTapes\Daily\.  
The best way to solve this would be to change anything concerning the share or file system that would permit symbolic links. If using NAS, it may be as simple as checking a check box on the server side. On the client side, it may be possible to mount the share or file system with certain options to allow symbolic linking.


Each virtual tape needs to be shared separately due to the way chg-disk works. It maintains a symlink called "data" which points to the currently 'loaded' slot. CIFS does not support symlinks, so sharing each tape allows the symlink to live on the local filesystem. On a Windows machine, sharing is quickly achieved from Windows Explorer, or by using the "net share" command. Share names like "AmandaTapes-daily-slot1" help to make sure your share names are not ambiguous across configs, or confused with other shares.
If creating symbolic links within the share or file system you want to use is not an option, below is a way to work around it. Another way would be to use the chg-multi changer script instead of chg-disk.  For full details this and setting up vtapes, please see [[How To:Set Up Virtual Tapes]].


As alternative, you can choose a setup with ''chg-multi'' instead of ''chg-disk'': that implementation does not use a symlink, and there you can use one toplevel share. See more in [[How To:Set Up Virtual Tapes]].
== Setup ==
 
Now that the vtapes are created, they need to be mounted on our Amanda server. This is done using mount.cifs from the Samba software suite. It requires a credentials file that you supply a valid Windows username and password for connecting to the share.  Here we use /etc/amandatapecredentials. The format of this is specified in the Samba documentation, and the [http://www.amanda.org/docs/samba.html#id2535698 Amanda documentation] where a similar file is used for connecting to Windows clients. Make sure the permissions are sufficiently tight on this file so that only root can access the file.
 
We also need to decide where to mount these tapes on our filesystem. Here we have gone for /amandatapes/Daily. So we have executed the following as root:
 
$ mkdir -p /amandatapes/Daily/slot1
...
$ mkdir -p /amandatapes/Daily/slotN
$ chown -R amanda:amanda /amandatapes
 
It is useful to have the vtapes mounted as soon as the Amanda server boots. On our example Linux server this is done by editing /etc/fstab to include new entries for our vtapes. These look something like the following:
 
//tapeserver/AmandaTapes-daily-slot1 /amandatapes/daily/slot1 cifs credentials=/etc/amandatapecredentials,uid=amanda,gid=amanda,rw 0 0
...
//tapeserver/AmandaTapes-daily-slotN /amandatapes/daily/slotN cifs credentials=/etc/amandatapecredentials,uid=amanda,gid=amanda,rw 0 0


We can mount them using
1. If it does not already exist, create the directory space on your non-symlink-supporting share or file system where the vtapes will actually be saved.  If the full share is writable by the Amanda user, you can simply create this directory as this user.
-bash-3.00$ '''mkdir -p /mnt/samba/vtapes/DailySet1'''
If you must be root to create this directory, make sure to set proper permissions for your Amanda user:
[root:/]# '''mkdir -p /mnt/samba/vtapes/DailySet1'''
[root:/]# '''chown amandabackup:disk /mnt/samba/vtapes/DailySet1'''
[root:/]# '''chmod 750 /mnt/samba/vtapes/DailySet1'''


  mount /amandatapes/daily/slot1
2. Create a virtual slot directory for every vtape you will be using (in this example, 15 tapes).  As the Amanda user
  ...
  -bash-3.00$ '''mkdir /mnt/samba/vtapes/DailySet1/slots'''
mount /amandatapes/daily/slotN
  -bash-3.00$ '''cd /mnt/samba/vtapes/DailySet1/slots'''
-bash-3.00$ '''for ((i=1; $i<=15; i++)); do mkdir slot$i; done'''


or even with
3. On an available file system that supports symbolic linking, create a directory structure for vtapes and use this directory as the file driver for the ''tapedev'' parameter in your ''amanda, conf'', for ex. '''tapedev file:/var/lib/amanda/vtapes/DailySet1'''.  The vtape directory will result in a small directory structure containing links and will require very little space of the file system (a few Kb).  You can create this right in your Amanda user's home directory, for instance.
As the Amanda user, create a directory for vtapes for your backup configuration
[amandabackup~]$ '''mkdir -p /var/lib/amanda/vtapes/DailySet1'''
If you create this in a place that requires root permission, make sure you set proper permissions for the new directory for your Amanda user
[root:/]# '''mkdir -p /var/lib/amanda/vtapes/DailySet1'''
[root:/]# '''chown amandabackup:disk /var/lib/amanda/vtapes/DailySet1'''
[root:/]# '''chmod 750 /var/lib/amanda/vtapes/DailySet1'''


  mount -a -t cifs
4. Enter this directory and create the links to the virtual slots in '''/var/lib/amanda/vtapes/DailySet1/slots''' as the Amanda user:
  -bash-3.00$ '''cd /var/lib/amanda/vtapes/DailySet1'''
-bash-3.00$ '''for ((i=1; $i<=15; i++)); do ln -s /mnt/samba/vtapes/DailySet1/slots/slot$i slot$i; done'''
-bash-3.00$ '''ln -s slot1 data'''
-bash-3.00$ '''ls -al'''
lrwxrwxrwx  1 amandabackup disk    5 Jun 15 11:27 data -> slot1
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot1 -> /mnt/samba/vtapes/DailySet1/slots/slot1
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot2 -> /mnt/samba/vtapes/DailySet1/slots/slot2
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot3 -> /mnt/samba/vtapes/DailySet1/slots/slot3
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot4 -> /mnt/samba/vtapes/DailySet1/slots/slot4
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot5 -> /mnt/samba/vtapes/DailySet1/slots/slot5
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot6 -> /mnt/samba/vtapes/DailySet1/slots/slot6
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot7 -> /mnt/samba/vtapes/DailySet1/slots/slot7
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot8 -> /mnt/samba/vtapes/DailySet1/slots/slot8
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot9 -> /mnt/samba/vtapes/DailySet1/slots/slot9
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot10 -> /mnt/samba/vtapes/DailySet1/slots/slot10
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot11 -> /mnt/samba/vtapes/DailySet1/slots/slot11
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot12 -> /mnt/samba/vtapes/DailySet1/slots/slot12
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot13 -> /mnt/samba/vtapes/DailySet1/slots/slot13
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot14 -> /mnt/samba/vtapes/DailySet1/slots/slot14
lrwxrwxrwx  1 amandabackup disk  40 Jun 15 11:26 slot15 -> /mnt/samba/vtapes/DailySet1/slots/slot15


if we want to mount all the CIFS-filesystems at once.
5. You can now label the tapes to be used by Amanda as the Amanda user:
-bash-3.00$ '''for ((i=1; $i<=9; i++)); do amlabel DailySet1 DailySet1-0$i slot $i; done'''
labeling tape in slot 1 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-01, checking label, done.
labeling tape in slot 2 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-02, checking label, done.
labeling tape in slot 3 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-03, checking label, done.
labeling tape in slot 4 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-04, checking label, done.
labeling tape in slot 5 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-05, checking label, done.
labeling tape in slot 6 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-06, checking label, done.
labeling tape in slot 7 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-07, checking label, done.
labeling tape in slot 8 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-08, checking label, done.
labeling tape in slot 9 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-09, checking label, done.
-bash-3.00$ '''for ((i=10; $i<=15; i++)); do amlabel DailySet1 DailySet1-$i slot $i; done'''
labeling tape in slot 10 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-10, checking label, done.
labeling tape in slot 11 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-11, checking label, done.
labeling tape in slot 12 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-12, checking label, done.
labeling tape in slot 13 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-13, checking label, done.
labeling tape in slot 14 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-14, checking label, done.
labeling tape in slot 15 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-15, checking label, done.


Now the vtapes need to be labeled using amlabel in the normal way.
See the article [[File driver]] for examples.


== Performance ==
== Performance ==

Revision as of 02:11, 12 November 2008

This article is a part of the How Tos collection.

Introduction

Amanda has the ability to use a harddisk to store the contents of backups onto virtual tapes (vtapes) using the file driver. The vtapes can be located on any filesystem, even a remote one.

If you are following the instructions under Using chg-disk in How To:Set Up Virtual Tapes and get to the point where you run

 $ ln -s slot1 data

and get

 ln: creating symbolic link `data': Operation not supported

you likely are trying to put your virtual tapes (vtapes) on a file system that does not support symbolic links. Unlike the chg-multi changer script, chg-disk uses a symbolic link to point to the currently active slot of your virtual tape changer. If you can't create the link above, neither can Amanda.

A common example of this is using CIFS to store our vtapes on a Windows machine. This is not specific to Windows, many NAS devices support CIFS.

The best way to solve this would be to change anything concerning the share or file system that would permit symbolic links. If using NAS, it may be as simple as checking a check box on the server side. On the client side, it may be possible to mount the share or file system with certain options to allow symbolic linking.

If creating symbolic links within the share or file system you want to use is not an option, below is a way to work around it. Another way would be to use the chg-multi changer script instead of chg-disk. For full details this and setting up vtapes, please see How To:Set Up Virtual Tapes.

Setup

1. If it does not already exist, create the directory space on your non-symlink-supporting share or file system where the vtapes will actually be saved. If the full share is writable by the Amanda user, you can simply create this directory as this user.

-bash-3.00$ mkdir -p /mnt/samba/vtapes/DailySet1

If you must be root to create this directory, make sure to set proper permissions for your Amanda user:

[root:/]# mkdir -p /mnt/samba/vtapes/DailySet1
[root:/]# chown amandabackup:disk /mnt/samba/vtapes/DailySet1
[root:/]# chmod 750 /mnt/samba/vtapes/DailySet1

2. Create a virtual slot directory for every vtape you will be using (in this example, 15 tapes). As the Amanda user

-bash-3.00$ mkdir /mnt/samba/vtapes/DailySet1/slots
-bash-3.00$ cd /mnt/samba/vtapes/DailySet1/slots
-bash-3.00$ for ((i=1; $i<=15; i++)); do mkdir slot$i; done

3. On an available file system that supports symbolic linking, create a directory structure for vtapes and use this directory as the file driver for the tapedev parameter in your amanda, conf, for ex. tapedev file:/var/lib/amanda/vtapes/DailySet1. The vtape directory will result in a small directory structure containing links and will require very little space of the file system (a few Kb). You can create this right in your Amanda user's home directory, for instance. As the Amanda user, create a directory for vtapes for your backup configuration

[amandabackup~]$ mkdir -p /var/lib/amanda/vtapes/DailySet1

If you create this in a place that requires root permission, make sure you set proper permissions for the new directory for your Amanda user

[root:/]# mkdir -p /var/lib/amanda/vtapes/DailySet1
[root:/]# chown amandabackup:disk /var/lib/amanda/vtapes/DailySet1
[root:/]# chmod 750 /var/lib/amanda/vtapes/DailySet1

4. Enter this directory and create the links to the virtual slots in /var/lib/amanda/vtapes/DailySet1/slots as the Amanda user:

-bash-3.00$ cd /var/lib/amanda/vtapes/DailySet1
-bash-3.00$ for ((i=1; $i<=15; i++)); do ln -s /mnt/samba/vtapes/DailySet1/slots/slot$i slot$i; done
-bash-3.00$ ln -s slot1 data
-bash-3.00$ ls -al
lrwxrwxrwx  1 amandabackup disk    5 Jun 15 11:27 data -> slot1
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot1 -> /mnt/samba/vtapes/DailySet1/slots/slot1
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot2 -> /mnt/samba/vtapes/DailySet1/slots/slot2
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot3 -> /mnt/samba/vtapes/DailySet1/slots/slot3
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot4 -> /mnt/samba/vtapes/DailySet1/slots/slot4
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot5 -> /mnt/samba/vtapes/DailySet1/slots/slot5
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot6 -> /mnt/samba/vtapes/DailySet1/slots/slot6
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot7 -> /mnt/samba/vtapes/DailySet1/slots/slot7
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot8 -> /mnt/samba/vtapes/DailySet1/slots/slot8
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot9 -> /mnt/samba/vtapes/DailySet1/slots/slot9
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot10 -> /mnt/samba/vtapes/DailySet1/slots/slot10
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot11 -> /mnt/samba/vtapes/DailySet1/slots/slot11
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot12 -> /mnt/samba/vtapes/DailySet1/slots/slot12
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot13 -> /mnt/samba/vtapes/DailySet1/slots/slot13
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot14 -> /mnt/samba/vtapes/DailySet1/slots/slot14
lrwxrwxrwx  1 amandabackup disk   40 Jun 15 11:26 slot15 -> /mnt/samba/vtapes/DailySet1/slots/slot15

5. You can now label the tapes to be used by Amanda as the Amanda user:

-bash-3.00$ for ((i=1; $i<=9; i++)); do amlabel DailySet1 DailySet1-0$i slot $i; done
labeling tape in slot 1 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-01, checking label, done.
labeling tape in slot 2 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-02, checking label, done.
labeling tape in slot 3 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-03, checking label, done.
labeling tape in slot 4 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-04, checking label, done.
labeling tape in slot 5 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-05, checking label, done.
labeling tape in slot 6 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-06, checking label, done.
labeling tape in slot 7 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-07, checking label, done.
labeling tape in slot 8 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-08, checking label, done.
labeling tape in slot 9 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-09, checking label, done.
-bash-3.00$ for ((i=10; $i<=15; i++)); do amlabel DailySet1 DailySet1-$i slot $i; done
labeling tape in slot 10 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-10, checking label, done.
labeling tape in slot 11 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-11, checking label, done.
labeling tape in slot 12 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-12, checking label, done.
labeling tape in slot 13 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-13, checking label, done.
labeling tape in slot 14 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-14, checking label, done.
labeling tape in slot 15 (file://var/lib/amanda/vtapes/DailySet1):
rewinding, reading label, not an amanda tape (Read 0 bytes)
rewinding, writing label DailySet1-15, checking label, done.


Performance

Performance using CIFS via Samba is known to be poorer than protocols such as FTP, HTTP and even CIFS on Windows. This is apparently due to Samba not using asynchronous writes, so each write has to be acknowledged by the server before the next one can take place.

Before deciding to use CIFS it would be advisable to test the speed of a transfer to a CIFS mount from your amanda server. Although bandwidth is an issue, latency also plays a big part.

More research on increasing performance is done and the results will be posted here.