We have moved to a new Sailfish OS Forum. Please start new discussions there.
3

Automatic Sync Fotos To digiKam Collection [answered]

asked 2017-09-09 02:39:46 +0300

prometheos de+it gravatar image

updated 2017-09-13 03:13:44 +0300

How can I automatically sync my new shot fotos to my foto collection under digiKam?

edit retag flag offensive reopen delete

The question has been closed for the following reason "the question is answered, an answer was accepted" by pawel
close date 2017-09-13 13:47:45.758239

2 Answers

Sort by » oldest newest most voted
1

answered 2017-09-12 09:41:03 +0300

juiceme gravatar image

I use a cronscript to sync the home directory my device every night, this way even as the sync is not immediate it will happen soonish. This syncs bot pictures and everything else which is generally nice. :)

Of course there is no problem to run rsync just on /home/nemo/Pictures and do this every 10 minutes for example; then you'd be pretty much synced all the time.

With my N9 I went even further, I had an inotify script that synced my photos immediately when a new one was taken. This way my webgallery was updated in real time when I took pictures. Same thing could be also done easily with SFOS.

See my cloudsync article for details.

edit flag offensive delete publish link more

Comments

+Does without systemd!
+A short answer!

prometheos de+it ( 2017-09-12 09:56:11 +0300 )edit

Use cron and you don't need systemd timers. :)

However if you want to set up an inotify-based immediate sync solution I suggest you should launch the notify script s a systemd service.

juiceme ( 2017-09-12 10:23:11 +0300 )edit
1

answered 2017-09-13 02:48:00 +0300

prometheos de+it gravatar image

updated 2017-09-13 16:56:30 +0300

Automated sync of my fotos to my digiKam desktop

I implemented this service - named Fotosync - on my Jolla1 using this =>"https://blog.simon-dreher.de/jolla-foto-backup.html, Creative Commons BY 3.0 by Simon Dreher as a guideline, with few further tweaks.

  • We will build on Jolla a systemd user service
  • which waits for a WLAN connection to the digiKam machine,
  • then uses ssh
  • to push all new made fotos of Jolla onto a COLLECTOR directory on it. Jolla plays the active role, while the digiKam machine has the passive role of collecting the data.
  • Communications take place only if Jolla and digiKam use a common WLAN router, inside the home network.
  • A dedicated encryption key is used exclusively for the fotosync traffic, blocking other usages of it.
  • The original system by Simon Dreher syncs every minute from his Jolla to his Home Server with Seafile (a very interesting Home Cloud).
  • I will sync fotos with my centralized Foto Archive, a digiKam Collection.
  • A digiKam Collection is a Directory Hierarchy plus some databases ,and digiKam plus KIPI plugins.
  • If digiKam then detects new Fotos in his subdirectories, it starts automatically to import and integrate them in its collection/database.
  • I can then later in digiKam take further steps on the fotos, like:
    • Move/copy them to other places,
    • rename them
    • tag them
    • produce special versions, as: smaller for mailing, very small for thumbnails etc.
    • And also: correct errors from Jolla, like camera metadata.

DOING

Preparing Jolla

  • Accessing the digiKam host through ssh public key authentication

We assume that we have already ssh access to nemo@Sailfish. This makes working on Jolla with a shell much more comfortable than with the on-board console alone.

We generate on Jolla a ssh key, which will be used solely for the fotosync service. Choose no passphrase.

[nemo@Sailfish ~]$ ssh-keygen -t rsa -f /home/nemo/.ssh/fotosync
  • Generating public/private rsa key pair.

For a comfortable working, add the hostname and the identity file to your /home/nemo/.ssh/config/ssh-config (adjusting them to Your case):`

Host Sailfish
    HostName Sailfish<.domainname>.de
    User $username
    IdentityFile ~/.ssh/fotosync
  • Settting up systemd:

Create a file '/home/nemo/.config/systemd/user/fotosync.path' with following content:

[Unit]
Description=Checks if paths changed or contain new images.`

[Path]
PathChanged=%h/Pictures/Camera

[Install]
WantedBy=default.target

Now create the file '/home/nemo/.config/systemd/user/backup.service' containing:

[Unit]    
Description=Syncs media files from Jolla to the digiKam Archive on (yourusername)@(yourdigiKammachine) and other gadgets.

[Service]
ExecStart=/home/nemo/bin/fotosync.sh

Create the sync procedure '/home/nemo/bin/fotosync.sh' with:

#!/bin/sh

#   TEST=;ssh nemo@Sailfish ./bin/fotosync.sh # 
# 

COLLECTOR="/home/<username>/images/$(date +%Y)/COLLECTOR" #

ssh  <username>@<digiKammachine> mkdir -p $COLLECTOR $LOGDIR; #

# Check if we are on wlan
if [ $(/sbin/ifconfig | grep -o wlan0) ]; then
    echo "WLAN used"
    # Start syncing using rsync
    time /usr/bin/rsync Pictures/Camera/ -vhCErltm <username>@<digiKammachine>:"$COLLECTOR"/ 
else
    echo "No WLAN"
    mkdir /tmp/backup.lock
    if [ $? -ne 0 ]; then
        echo "Another script is already waiting for WLAN to sync."
        exit 0
    else
        # Wait for WLAN to come back
        until [ $(/sbin/ifconfig | grep -o wlan0) ]; do
            echo "Still no WLAN"
            sleep 60
        done
       time /usr/bin/rsync Pictures/Camera/ -vhCErltm <username>@<digiKammachine>:"$COLLECTOR"/ 
        rm -rf /tmp/backup.lock
    fi
fi

exit #

Note that here we extablish where we collect our pictures under digiKam:

On the first usage in the year we create a new subdirectory named <year number="">, like '2017', inside Your collection, with a new dir 'COLLECTOR' inside, where the new pictures get collected.</year>

Preparing the digiKam machine

I cannot do it better nor shorter than Simon Dreher, whom I quote here literally:

"For the SSH connection the server has to know the public key and therefore you have to somehow get '~/.ssh/fotosync.pub' or how you called the SSH keyfile in part one onto your server. There you have to append it to '~/.ssh/authorized_keys'.

cat fotosync.pub >> .ssh/authorized_keys

I recommend that you secure this ssh access since the key file lies on a mobile device and is not protected by a passphrase.

You can add two v to the options of the rsync command in the shell script. Then it's more verbose and shows you which command is executed on the server.

rsync --server -vvlmtErCe.iLs . /mnt/Bilder/Jolla

This command can now pasted into the authorized_keys file before the appended key, on the same line:

command="rsync --server -lmtErCe.iLs . /mnt/Bilder/Jolla",no-agent-forwarding,no-port-forwarding,no-pty,no-user-rc,no-X11-forwarding ssh-rsa AA...

Now this is the only command that can be executed with this SSH key. Note that if you remove the vv from the script you also have to remove them from the authorized_keys file."

Note the text "/Bilder/Jolla", from the German installation of Jolla. You may have to change it for Your needs, after looking on Your installation.

  • Start the new systemd service

"Now run the script manually once to test and add fingerprint to known hosts. If everything worked we can now enable our systemd files:

systemctl --user start backup.path
systemctl --user enable backup.path

Note the "--user" parameter, which avoids using root. The sevice will then not show up with "systemctl", but only with "systemctl --user status fotosync.path".

Now we can take a photo and magically it syncs to your server and all your other devices. Tadaa."

Thanks to Simon Dreher for his page =>"https://blog.simon-dreher.de/jolla-foto-backup.html".

edit flag offensive delete publish link more

Question tools

Follow
4 followers

Stats

Asked: 2017-09-09 02:39:46 +0300

Seen: 877 times

Last updated: Sep 13 '17