1 Reply Latest reply: Dec 30, 2009 8:30 AM by 807567 RSS

    Novice question about TAR and Symbolic Links...

    807567
      Greetings,

      I am in the process of developing a procedure for migrating a MediaWiki wiki from source server A to destination server B. Part of the procedure involves copying three MediaWiki directories with their subdirectories and files from source to destination. I have decided to use tar to archive the necessary directories and files. Once I have the tar archives, I will transfer them to the destination server and extract.

      I need help deciding whether or not to use the -h or --dereference option when I tar archive two of the three directories.  The /etc/mediawiki directory does not have any symbolic links, but there are symbolic links between the /var/lib/mediawiki and /usr/share/mediawiki directories.

      Here are my questions:
      1. If I do not use the -h option when I tar /var/lib/mediawiki and /usr/share/mediawiki on server A and then extract on server B, will the symbolic links between the two directories be broken?

      2. If I do use the -h option when I tar /var/lib/mediawiki and /usr/share/mediawiki on server A and then extract on server B, will the symbolic links be preserved?

      Here are the directory listings for /var/lib/mediawiki and /usr/share/mediawiki with the symbolic links:
      root@915PBL:/var/lib/mediawiki# ls -l
      total 12
      lrwxrwxrwx 1 root     root       32 2009-12-28 16:39 AdminSettings.php -> /etc/mediawiki/AdminSettings.php
      lrwxrwxrwx 1 root     root       28 2009-12-28 16:39 api.php -> /usr/share/mediawiki/api.php
      drwx------ 2 www-data www-data 4096 2009-12-28 19:37 config
      drwxr-xr-x 3 root     root     4096 2009-12-28 18:57 extensions
      drwx------ 2 www-data www-data 4096 2009-07-27 09:48 images
      lrwxrwxrwx 1 root     root       33 2009-12-28 16:39 img_auth.php -> /usr/share/mediawiki/img_auth.php
      lrwxrwxrwx 1 root     root       29 2009-12-28 16:39 includes -> /usr/share/mediawiki/includes
      lrwxrwxrwx 1 root     root       30 2009-12-28 16:39 index.php -> /usr/share/mediawiki/index.php
      lrwxrwxrwx 1 root     root       38 2009-12-28 16:39 install-utils.inc -> /usr/share/mediawiki/install-utils.inc
      lrwxrwxrwx 1 root     root       30 2009-12-28 16:39 languages -> /usr/share/mediawiki/languages
      lrwxrwxrwx 1 root     root       32 2009-12-28 16:39 LocalSettings.php -> /etc/mediawiki/LocalSettings.php
      lrwxrwxrwx 1 root     root       32 2009-12-28 16:39 maintenance -> /usr/share/mediawiki/maintenance
      lrwxrwxrwx 1 root     root       40 2009-12-28 16:39 opensearch_desc.php -> /usr/share/mediawiki/opensearch_desc.php
      lrwxrwxrwx 1 root     root       36 2009-12-28 16:39 profileinfo.php -> /usr/share/mediawiki/profileinfo.php
      lrwxrwxrwx 1 root     root       33 2009-12-28 16:39 redirect.php -> /usr/share/mediawiki/redirect.php
      lrwxrwxrwx 1 root     root       35 2009-12-28 16:39 redirect.phtml -> /usr/share/mediawiki/redirect.phtml
      lrwxrwxrwx 1 root     root       26 2009-12-28 16:39 skins -> /usr/share/mediawiki/skins
      lrwxrwxrwx 1 root     root       38 2009-12-28 16:39 StartProfiler.php -> /usr/share/mediawiki/StartProfiler.php
      lrwxrwxrwx 1 root     root       30 2009-12-28 16:39 thumb.php -> /usr/share/mediawiki/thumb.php
      root@915PBL:/var/lib/mediawiki#
      root@915PBL:/usr/share/mediawiki# ls -l
      total 88
      lrwxrwxrwx  1 root root    36 2009-12-28 16:39 AdminSettings.php -> /var/lib/mediawiki/AdminSettings.php
      -rw-r--r--  1 root root  3321 2009-05-05 07:07 api.php
      lrwxrwxrwx  1 root root    25 2009-12-28 16:39 config -> /var/lib/mediawiki/config
      lrwxrwxrwx  1 root root    29 2009-12-28 16:39 extensions -> /var/lib/mediawiki/extensions
      lrwxrwxrwx  1 root root    25 2009-12-28 16:39 images -> /var/lib/mediawiki/images
      -rw-r--r--  1 root root  3192 2009-03-21 09:48 img_auth.php
      drwxr-xr-x 13 root root  4096 2009-12-28 16:39 includes
      -rw-r--r--  1 root root  4281 2009-03-20 05:00 index.php
      -rw-r--r--  1 root root  3952 2009-03-21 09:48 install-utils.inc
      drwxr-xr-x  4 root root  4096 2009-12-28 16:39 languages
      lrwxrwxrwx  1 root root    36 2009-12-28 16:39 LocalSettings.php -> /var/lib/mediawiki/LocalSettings.php
      drwxr-xr-x 12 root root 12288 2009-12-28 16:39 maintenance
      -rw-r--r--  1 root root  3054 2009-03-21 09:48 opensearch_desc.php
      -rw-r--r--  1 root root  9140 2008-12-09 19:59 profileinfo.php
      -rw-r--r--  1 root root   383 2009-03-21 09:48 redirect.php
      -rw-r--r--  1 root root    91 2005-01-31 12:35 redirect.phtml
      drwxr-xr-x  9 root root  4096 2009-12-28 16:39 skins
      -rw-r--r--  1 root root   603 2009-01-07 13:11 StartProfiler.php
      -rw-r--r--  1 root root  4392 2008-12-01 09:14 thumb.php
      -rw-r--r--  1 root root  1347 2008-11-05 08:54 trackback.php
      -rw-r--r--  1 root root    88 2005-01-31 12:35 wiki.phtml
      root@915PBL:/usr/share/mediawiki#
      Thanks,
      Greg
        • 1. Re: Novice question about TAR and Symbolic Links...
          807567
          I ran an experiment to answer my question.

          Server A has directory /etc/directoryA and /etc/directoryB. Server B does not have /etc/directoryA or /etc/directoryB.

          A symbolic link was created on Server A in directoryA to a file (FileBX, already in existence) in directoryB like this (from /etc/directoryA):
          ln -s symblink1 /etc/directoryB/FileBX

          Both directoryA and directoryB on Server A were archived with tar like this (from /etc):
          tar -czvf backupA.tar.gz directoryA
          tar -czvf backupB.tar.gz directoryB

          Both backup files were moved to the /etc directory on Server B and then unzipped like this:
          gunzip backupA.tar.gz
          gunzip backupB.tar.gz

          Both archive tar files were extracted on Server B from the /etc directory like this:
          tar -xvf backupA.tar
          tar -xvf backupB.tar

          The symbolic link from /etc/directoryA/symblink1 to /etc/directoryB/FileBX was tested like this (from /etc/directoryA):
          vi symblink1

          The result was the data from /etc/directoryB/FileBX

          I am concluding that if one makes tar archives of all the directories containing symbolic links between each other and then properly extracts those same tar archives on a different system that the symbolic links will function. Good.