[SOLVED] Path to FreeFileSync (flatpak)

Get help for specific problems
Posts: 13
Joined: 27 Apr 2021

Franzmint

Hi Forum,
I'm new in the linux world. I have installed FreeFileSync with GUI Application Manager of Linux Mint (flathub). Now I want to set up a cronjob, but I am not able to find out the path to FreeFileSync. Can you please help me - how can I find the place, where the Application Manager has installed FreeFileSync?
Thank you!
Last edited by Franzmint on 29 Apr 2021, 06:22, edited 1 time in total.
Posts: 306
Joined: 7 Jan 2018

bgstack15

I don't know flatpak specifics, but you could start with a generic command from a terminal window:
which FreeFileSync
It's possible the binary is named FreeFileSync.bin.
which FreeFileSync.bin
Some builds have the architecture as part of the filename, so FreeFileSync_x86_64 or similar. If any "which" command shows a full path to a binary, try running that full path on the command line and ensure it starts up FreeFileSync.
Alternatively, you can go try to modify the menu entry for FreeFileSync to see what its Exec= line is. Linux Mint uses Cinnamon as the desktop environment, and Cinnamon follows the XDG desktop entry spec (which is actually closely related to the Flatpak project), so you can go check for a FreeFileSync.desktop file in /usr/share/applications and/or your home directory. Run this command:
find /usr/share/applications ~ -iname '*freefilesync*.desktop'
The shell (what runs the commands, in the terminal) interprets the tilde ~ character as your home directory (so most likely /home/Franzmint), so this command will print the names of any file whose name matches that case-insensitive search expression. There will be at least one response, if your menu shows FreeFileSync at all. Go edit or view that file in your favorite text editor, and learn what the Exec= line is. Mine is
Exec=FreeFileSync %f
Which means that it doesn't use a fully qualified pathname, so FreeFileSync is already in my $PATH environment variable, which is the list of directories to search for commands in. That is, if $PATH=/usr/bin:/bin then FreeFileSync must be in one of those two directories (or else my menu entry wouldn't work).
To check your $PATH, just echo it.
echo $PATH
Flatpak probably uses some crazy ~/.local/share/flatpak/usr/bin path or similar, but I don't know for sure.

Now, once you find your FreeFileSync binary path, you will need to set up cron with the ability to run FreeFileSync (which is a graphical application) in a graphical shell. I would use Xvfb (apt-get install xvfb) which is X virtual framebuffer, which tricks programs into thinking they have a graphical environment. So either xvfb or just running it with environment variable DISPLAY=:0 which always gets tricky (please search this forum for "cron DISPLAY").
For Xvfb, you would set up a cron entry similar to the following:
0 1 * * *  xvfb /usr/bin/path/to/FreeFileSync_x86_64 /home/Franzmint/my-sync.ffs_batch 1>/home/Franzmint/logs/ffs.cron.log 2>&1
(Note, I haven't tested this with Xvfb with FreeFileSync from cron, but I've used Xvfb for other headless "graphical" applications)
Posts: 13
Joined: 27 Apr 2021

Franzmint

Thank you very much bgstack15 for this detailed answer!!!!
I have found this line in .desktop file:
Exec=/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=FreeFileSync --file-forwarding org.freefilesync.FreeFileSync @@ %F @@
This does not show me the path - or does is? It looks like there is a flatpak command with some parameters. Can I use this in crontab, too?
Posts: 13
Joined: 27 Apr 2021

Franzmint

Or other idea: would it be better to uninstall flatpak version and to install version of freefilesync website instead?
Posts: 306
Joined: 7 Jan 2018

bgstack15

If the Flatpak version operates how you want it to, there should be no reason to do anything different. I suppose that yes, you could put the value of the Exec= into the cron job. The @@ %F @@ of course is the placeholder for the filename of the ffs_batch file.
I have no clue if flatpak will work when being run as root. That's usually a bad idea, running graphical programs as root (regardless of what packaging technology is involved), and it could be blocked by the flatpak tech.
Here's another idea: when FreeFileSync is running, run this command in a terminal to see what programs are running:
ps -ef | grep -i freefilesync
And the output might show you the path to a FreeFileSync binary.
Posts: 13
Joined: 27 Apr 2021

Franzmint

Wow, I thought the cronjob things would be a little bit easier. For me as a linux beginner, they were not :-(
But with your help and another forum post, I have succeeded:
1.) I have uninstalled the flatpak version of FreeFileSync
2.) I have downloaded the run-file of FreeFileSync website and installed this instead.
3.) Now pathes are no longer a problem, as installation told me the path to FreeFileSync ;-)
4.) Despite of this, cronjob seemed not to work. As I found out, because DISPLAY parameter was missing.
So here is my final crontab line working fine on Linux Mint 20:
55 07 * * * /home/myname/FreeFileSync/FreeFileSync /home/myname/backup_keepass/Profile/Sicherung_Keepass_lokal.ffs_batch --display=:0.0 2>&1
At 07:55 in the morning, this cronjob starts. A FreeFileSync windows opens - for me that's fine.

Thank you very much, bgstack15!!!
Posts: 1
Joined: 3 Jul 2022

blehmann

I ran into the same issue with Ubuntu 20.04. However, I managed to schedule a backup using the Flatpak version with crontab.

1. I found the execution command in the Desktop icon.
/usr/bin/flatpak run --branch=stable --arch=x86_64 --command=FreeFileSync --file-forwarding org.freefilesync.FreeFileSync @@ %F @@
- replace the @@ %F @@ with the path to your batch file

2. Use the user crontab (crontab -e), not the root version ( sudo crontab -e). This seems to the be the key issue. As mentioned above, running in root is not a good idea anyway.

3. My full crontab entry is :
15 1 * * * DISPLAY=:0.0 /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=FreeFileSync --file-forwarding org.freefilesync.FreeFileSync /home/lehmann/SyncSettingsNAS1.ffs_batch 1>>/home/lehmann/standardoutput.log 2>>/home/lehmann/standarderror.log
When the program runs the progress chart will appear. You'll have to close it when it's done, but it's confirmation that backup occurred. This happens with the Windows version of FreeFileSync as well.

I hope this helps others. I nothing else, I'll have a reference if I have to rebuild by system.