Automatic Sync Fotos To digiKam Collection [answered]
How can I automatically sync my new shot fotos to my foto collection under digiKam?
We have moved to a new Sailfish OS Forum. Please start new discussions there.
How can I automatically sync my new shot fotos to my foto collection under digiKam?
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.
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.
DOING
Preparing Jolla
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
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
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.
"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".
This thread is public, all members of Together.Jolla.Com can read this page.
Asked: 2017-09-09 02:39:46 +0200
Seen: 925 times
Last updated: Sep 13 '17
I want a hardware keyboard with solar charger TOH [answered]
Markdown basics [not relevant]
[Implemented in 1.0.4.20] WiFi tethering [released]
[How-To] WPA-802.1X (enterprise), eduroam +[Others] GUI wifi support needed + workaround [released]
Prevent accidental shutdown [answered]
A dual sim with TOH [not relevant]
Jolla applications should be preinstalled with a new device [not relevant]
iCloude or Skydrive type services on Jolla
Fixed sorting of application covers on home screen [released]
[Implemented in 1.0.3.8] After screen time out, return to last active app [released]