How to get last image symbolic link

Hi all,
in Urbackup server there’s the special folder “<path_to_urbackup>/urbackup/clients” that give me a symbolic link to the last available backup for every client.

Is there a symbolic link to the last image backup available?
So, I would have 2 different symbolic links:

  1. the last file backup
  2. the last image backup

Is it possible or already implemented?

Thanks

[root@backup01 /]# ls -ld /backup/$CLIENT/*Image_C | tail -1
drwxr-x—. 2 urbackup urbackup 4096 Sep 17 18:14 /backup/$CLIENT/250917-1803_Image_C

Tweak $CLIENT as appropriate.

Thanks for the command.

But I should have specified that what I was asking for, was a “fixed” link.
What I want to do is copy Urbackup backups to USB disks, so I can follow the symbolic link “<path_to_urbackup>/urbackup/clients” to copy last file backup.
I would have another link (e.g. “<path_to_urbackup>/urbackup/clients_image”) to copy last image backup, if present.

I don’t know if there’s anything out of the box that does it, but, this ran out of a cronjob at a regular interval should do the trick. (I’d keep the symlink target OUT of the backup filesystem for safety’s sake)

ln -s `ls -d /backup/$CLIENT/*Image_C | tail -1` /tmp/symlink

You could wrap it in loop if you’re feeling froggy… (Not well tested code):

#!/bin/bash

/bin/mkdir -p /tmp/symlink
for CLIENT in `(cd /backup/clients; /bin/ls)`
do
        /bin/rm -rf /tmp/symlink/${CLIENT}
        /bin/mkdir /tmp/symlink/${CLIENT}
        lastImage=`/bin/ls -d /backup/$CLIENT/*Image_C 2>/dev/null | /bin/tail -1`
        if [ "${lastImage}""x" != """x" ]; then
                /bin/ln -s "${lastImage}" /tmp/symlink/${CLIENT}
        fi
done

But no, I don’t think this is outta the box functionality…

David

Great code David!

Thank you very much