Hi all,
Let me start off by saying the following:
- This isn’t a problem with Manjaro. Or anything but my brain/understanding, really.
- So if it’s not correctly placed, feel free to move it.
I am trying to create a systemd
timer unit to create daily backups for me. Currently, it’s not automatic but I want to change it. The last time I setup automatic anything on Linux, I used a cron job, and while that is still an option, I know the other, perhaps even better option is systemd timer units. So I’m trying to do it that way. But I’m sort of stumped.
The command I use for it, in the terminal is basically in the following format:
<rclone command to run> && <notify-send command for succeess> || <kdialog command for error>
This way I can keep tabs on it. Maybe even hold a log of what happened. But that’s not why I’m asking for assistance.
My reason is that I’m constantly getting error when from the .service
file part of the timer unit. The error:
Jun 27 13:25:09 Mirdarthos-PC systemd[1]: /etc/systemd/system/backup-keepass.service:7: Ignoring unknown escape sequences: "/usr/bin/rclone copy --copy-links /mnt/5T/Mirdarthos'\ Stuff/Documents/KeePass Database Onedrive:unencryptedData/KeepassXC\ Dat>
Jun 27 13:25:09 Mirdarthos-PC systemd[1]: /etc/systemd/system/backup-keepass.service:7: Executable name contains special characters: /usr/bin/rclone copy --copy-links /mnt/5T/Mirdarthos'\ Stuff/Documents/KeePass Database Onedrive:unencryptedData/Keepa>
Jun 27 13:25:09 Mirdarthos-PC systemd[1]: backup-keepass.service: Unit configuration has fatal error, unit will not be started.
Or:
Jun 27 13:25:43 Mirdarthos-PC systemd[1]: /etc/systemd/system/backup-keepass.service:6: Ignoring unknown escape sequences: "/mnt/5T/Mirdarthos'\ Stuff/Documents/KeePass"
Jun 27 13:25:43 Mirdarthos-PC systemd[1]: /etc/systemd/system/backup-keepass.service:6: Ignoring unknown escape sequences: "Onedrive:unencryptedData/KeepassXC\ Database/"
Jun 27 13:25:43 Mirdarthos-PC systemd[1]: /etc/systemd/system/backup-keepass.service:6: Ignoring unknown escape sequences: "Copy of \<b\>\<i\>KeepassXC database, unencrypted\<\/i\>\<\/b\> successfully finished."
Jun 27 13:25:43 Mirdarthos-PC systemd[1]: /etc/systemd/system/backup-keepass.service:6: Ignoring unknown escape sequences: "--msgbox=There was an error copying the \<b\>\<i\>KeepassXC database, unencrypted\<\/i\>\<\/b\>."
Or
Jun 27 13:15:15 Mirdarthos-PC systemd[1]: /etc/systemd/system/backup-keepass.service:6: Unbalanced quoting, ignoring: "/usr/bin/rclone copy --copy-links /mnt/5T/Mirdarthos' Stuff/Documents/KeePass Database Onedrive:unencryptedData/KeepassXC Database/ >
Jun 27 13:15:15 Mirdarthos-PC systemd[1]: backup-keepass.service: Unit configuration has fatal error, unit will not be started.
My /etc/systemd/system/backup-keepass.service
file:
[Unit]
Description=Backup KeepassXC database to Microsoft Onedrive.
[Service]
Type=simple
ExecStart=/usr/bin/rclone copy --copy-links /mnt/5T/Mirdarthos\'\ Stuff/Documents/KeePass Database Onedrive:unencryptedData/KeepassXC\ Database/ && kdialog --title 'Rclone copy: Onedrive cloud backup' --passivepopup 'Copy of \<b\>\<i\>KeepassXC database, unencrypted\<\/i\>\<\/b\> successfully finished.' 5 || kdialog --ok-label='OK' --msgbox='There was an error copying the \<b\>\<i\>KeepassXC database, unencrypted\<\/i\>\<\/b\>.'
Don’t worry, this KeepassXC database is quite safe behind a strong password and a key file.
At first I thought it might be escaping, so I escaped all paths with \
where there was a special/funny character. But it still wasn’t working. After quite a bit of hair-pulling, I’ve come to the conclusion that it’s because of the conditionals in the ExecStart
decleration.
So I’m considering changing it tto a OneShot
service with multiple ExecStart
declerations.
But, and this is what I want to ask, I’m having trouble fineding out if there can be Conditional ExecStart
declerations. Execute a command depending if the command was successful and another command if not. And if so, how to do it? I can create a bash script for thiss, but I don’t really know if that’s the proper way of doing something that is so relatively simple.
Any advice?