[.desktop file] Dolphin Root Service Menu - Create Timestamped Backups:

Dolphin Root Service Menu Copy +

Garuda includes a Dolphin service menu to easily create a duplicate/backup copy of a file via the Dolphin right click context menu. However, this cannot be used to backup root files. I find this an annoying limitation and I figured I needed to do something about this. I thought I'd try my hand at writing my own Dolphin service menu to do exactly what I wanted.

Oftentimes I edit some root configuration files many times over. It's nice to have an easy right click option to backup various versions that I've edited over time and automatically name/number them in the order they were created.

The Dolphin menu item I created will duplicate the file you right click on, and append a timestamp and a .bak suffix to the files original name. This way you can make versioned backups that will be listed in Dolphin chronologically by the order of creation.

This root Dolphin Service Menu will create a timestamped backup copy of any root file via Dolphin's right click context menu. You simply need to create the required .desktop file in the location that Dolphin utilizes for Service Menus.

Create the required directory/subdirectories:

mkdir -p ~/.local/share/kservices5/ServiceMenus

To create and open the required desktop file with the Kate text editor, run in terminal:

kate -n /home/$USER/.local/share/kservices5/ServiceMenus/bak.desktop > /dev/null 2>&1 & disown

In the Kate text editor, paste the following contents into your newly created bak.desktop file:

[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/all
Actions=bak;
X-KDE-Priority=TopLevel
X-KDE-StartupNotify=false
Icon=application-x-trash

[Desktop Action bak]
Name=Backup here (Root)
Icon=application-x-trash
Exec=pkexec cp -rf %f %f"$(date -Iminutes)".bak

Save the desktop file in Kate.

Make the desktop file executable:

chmod +x $HOME/.local/share/kservices5/ServiceMenus/bak.desktop

After completing these steps, restart all Dolphin instances.

To me, this seemed like a preferential way to backup versioned copies of root configuration files, rather than installing a dedicated program to do that for me.

Simply right click on a root file in Dolphin and then click on Backup here (root) to create a versioned/timestamped backup copy.

Example:

Right click on /etc/fstab
Click on Backup here (root)
Enter your password in the prompt window.
This will create a new timestamped backup copy such as:

/etc/fstab2022-03-15T13:53-07:00.bak

You may need to press F5 sometimes to refresh Dolphin's view for the newly created timestamped backup file to become visible. Although it shows up reliably on my system after creation.

I hope some of you like this Service Menu item, as this is far less hassle than trying to do the same thing from the terminal in my opinion.

10 Likes

Wow, nice one! It works great, you can grab a whole directory path too!

2 Likes

Right on. :nerd_face: :ninja: --- Good one @tbg

This Post is also a good place to learn about creating *.desktop files in general. Maybe put the word .desktop or some such in the OP Title to make it readily searchable. Or... actually this would be a great topic for a FAQ/Guide/HOWTO.

I'll search the forum to check if any Guide to Creating Desktop [ *.desktop ] files already exists before I move forward.

-Enjoy :coffee:
Cannabis

1 Like