Sample Header Ad - 728x90

Running backup script at shutdown (using rclone utility)

0 votes
0 answers
361 views
**General**: I want to run a back-up script during shutdown (not reboot). I've tried tons of systemd's service configuration, but no one is working. **Aim**: When PC is shutting down I want to perform a back-up to cloud storage using bash script and rclone utility. Syncing may take some time (up to several minutes) and it requires networking and a user being logged in. **Question**: What the appropriate .service file structure for my bash script ? Now I have something like this and it doesn't work at all. Script doesn't run at shutdown. [Unit] Description=Syncing with MEGA cloud storage 35 DefaultDependencies=no Conflicts=reboot.target After=network-online.target Before=shutdown.target halt.target poweroff.target [Service] User=yevhenii Type=oneshot ExecStart=/bin/true ExecStop=/home/yevhenii/Projects/ubuntu-scripts/mega_sync_pc.sh RemainAfterExit=true TimeoutSec=0 StandardOutput=file:/home/yevhenii/Projects/ubuntu-scripts/output.txt StandardError=file:/home/yevhenii/Projects/ubuntu-scripts/error.txt [Install] WantedBy=shutdown.target poweroff.target halt.target P.S. I'm using Ubuntu 19.10 & systemd 242
Asked by Yevhenii Nadtochii (121 rep)
Apr 12, 2020, 02:37 PM
Last activity: Mar 12, 2024, 10:55 PM