2

Every time I try to setup a symbolic link (symlink) I stuggle to get my head around symlink source and target.

I have tried this a few ways and it continues to fail.

Let me explain. BackupPC v4.4.0 stores backups in /var/lib/BackupPC by default. BackupPC installation instructions suggests using a symlink so future updates do not overwrite the backup directory location (/var/lib/BackupPC).

I want to store these in /dataR6 directory. (A raid 6 array.)

So, BackupPC stores in /var/lib/BackupPC that will be linked to store in /dataR6. Client backups storing in /dataR6 (directory.)

Both directories already exist.

I have read: Create a symbolic link relative to the current directory

And I read this: https://stackoverflow.com/questions/9104337/create-a-symbolic-link-of-directory-in-ubuntu/9104384#9104384

But, I still cannot get the link to connect properly.

So, my "source and target" question is, in the above case, which, is the source and which is the target? I'm thinking "source" = /var/lib/BackupPC and "target" = /dataR6? Or am I backwards?

Symlinks is a roundrobin stuggle for me of which is which and is VERY confusing. (Maybe I'm brain dead?)

2 Answers2

2

If you want /var/lib/BackupPC to point to and be the equivalent of target /dataR6, you need to replace it with a symbolic link

cd /var/lib
mv BackupPC BackupPC.dir
ln -s /dataR6 BackupPC
Chris Davies
  • 116,213
  • 16
  • 160
  • 287
2

A relevant source of confusion between "source" and "target" is probably the documentation itself. According to POSIX, "target" is the to-be-created link (or the directory links are being created into):

ln [-fs] [-L|-P] source_file target_file

[...]
DESCRIPTION
In the first synopsis form, the ln utility shall create a new directory entry (link) at the destination path specified by the target_file operand. [...]

According to the GNU man page, "target" is the file a link points to:

ln [OPTION]... [-T] TARGET LINK_NAME

[...]
DESCRIPTION
In the 1st form, create a link to TARGET with the name LINK_NAME. [...]

It may be easier to avoid those two words and think in terms of "file" (your data) and "link" (an alternative name for the file) instead.

Also, some mnemonic help may come from considering that ln -s /path/to/file (one argument) creates a link to /path/to/file in the current working directory. In this form, the argument that can not be omitted is the file, and thus the best is for it to be the first one.

You can then think about creating a symbolic link as ln -s the_data a_link_to_it (where a_link_to_it can also be read as "another path to the data").

A convenient use of symbolic links is supporting the definition of conventional paths: in your case, /var/lib/BackupPC is the path BackupPC is configured to use, and defining it as a symbolic link allows the program to work even if the real data is located somewhere else.

Hence, what you need is ln -s /dataR6 /var/lib/BackupPC, where /dataR6 is "the data" and /var/lib/BackupPC is "another way to reach it".

See roaima's answer for what you need to do in practice.

fra-san
  • 10,205
  • 2
  • 22
  • 43
  • Your explanation really helped me capture the correct "thinking" required to understand symbolic links (symlinks). THANK YOU!!!! – Robert Wooden Oct 28 '20 at 16:49