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.