Announcement

Collapse
No announcement yet.

Some other way to run my backup script at shutdown?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    Sorry, I wasn't avoiding you... But yes, my platform is a tad different. We've been using systemd for quite a while now and what seems obvious to me in Arch is mightily different in Kubuntu (my daughter runs Kubuntu, so I have to try to keep up).
    That being said, I still believe that there's a wealth of knowledge on the interwebs to help learn systemd. And I'm beginning to think that maybe a different way to go about this. What about going to systemsettings-->startup and shutdown-->autostart, add your script and set it to run on shutdown?
    I do not personally use Kubuntu, but I'm the tech support for my daughter who does.

    Comment


      #17
      I did take a look at that before all this but no success then, however looking again can't hurt. From the Internet searches I've been doing, I can see what you mean about Arch and yes I see that the architecture is quite different too. Strangely there is very little from anyone concerning my problem, so I'm guessing that the difference in architecture solves the problem before it arises. Also its very early days here at Kubuntu, so there will probably be adjustments made that might create an answer. In addition there are unpleasant rumblings in the background, it appears there has been much bad feeling, we are not aboard a happy ship. Looking for answers, solving problems, striving for improvement are not the watchwords right now, I'm guessing. Much of this is well over my head. I'm only a humble user of the system, though I've had quite a few years good experience. My little problem might well have to wait, perhaps even it is a bug of sorts. At least hourly backups still work, for now at least.
      ...and this is forcing me, unwillingly I must admit, to look at systemd and what it entails.
      As I say, I value your attention, but maybe we are just chasing our tails? Could be that time will put all this right, or force a change of course even? I think that what is pretty obvious is that solving this should be no big deal. The problem might well be outside of my ability and those that could sort it might not be so inclined right now.
      Perhaps another look on the Ubuntu Forums might give it the push it needs. I will try that approach I think.
      So thanks again Buddlespit, have a nice weekend

      *later*

      What about going to systemsettings-->startup and shutdown-->autostart, add your script and set it to run on shutdown?
      I tried the above but no joy I'm afraid. I'm still getting hourly backups, so the script itself is working okay. Its something about shutdown that is disallowing my script.
      Last edited by bobbicat; May 30, 2015, 05:25 AM.

      Comment


        #18
        I'm pleased to report that I have successfully achieved my aim, which was to set up a backup which runs at reboot, shutdown and halt.

        here is my file, backup.service:

        Code:
        [Unit]
        Description=local-backup at shutdown
        Before=shutdown.target reboot.target halt.target
        [Service]
        ExecStart=/bin/true
        ExecStop=/path/to/backup/script/local-backup.sh
        RemainAfterExit=yes
        [Install]
        WantedBy=multi-user.target
        I saved it as /lib/systemd/system/backup.service

        I then executed these two commands:

        Code:
        sudo systemctl start backup
        Code:
        sudo systemctl enable backup
        my backup system thereby became operational.

        I had tried variations on this unit, placed in different locations without success. It seems from trial and error that /lib/systemd/system/ is the place to go.

        I am open to being better informed but now at least I have something that works.
        I will look at setting up hourly backups using a .service file, next.

        Thanks to Buddlespit who pointed me in the right direction.
        (and here is a link to some info I found invaluable --> https://wiki.archlinux.org/index.php/Systemd)
        Last edited by bobbicat; Jun 11, 2015, 01:43 PM.

        Comment


          #19
          To enable hourly backups requires two files:
          Code:
          kdesudo kate
          # copy and paste the following into kate
          Code:
          [Unit]
          Description=local-backup
          [Service]
          Type=simple
          # Edit line below to substitute the path to your backup script
          ExecStart=/path/to/script/local-backup.sh
          # save as /lib/systemd/system/local-backup.service

          # close and reopen kate
          Code:
          kdesudo kate
          # copy and paste the following into kate
          Code:
          [Unit]
          Description=Local-backup every hour
          
          [Timer]
          # Time to wait after booting before we run first time
          OnBootSec=30min
          # Time between running each consecutive time
          OnUnitActiveSec=1h
          Unit=local-backup.service
          
          [Install]
          WantedBy=multi-user.target
          # save as /lib/systemd/system/local-backup.timer

          # Start timer
          Code:
          sudo systemctl start local-backup.timer
          # Enable timer to start at boot
          Code:
          sudo systemctl enable local-backup.timer
          hourly backups should begin after next boot

          Comment


            #20
            The files and folders used in this backup procedure are described a few posts above this.


            The modifications outlined here became necessary as systemd became default in Kubuntu 1504 Vivid Vervet.

            Any comments, suggestions or corrections are very welcome. Much of my learning has been by trial and error. I am always open to progress and improvement.

            I'll be taking a look at Arch, the Forums seem to come up with answers a non-geek like myself can work with.
            I found this page on the Arch wiki a good reference:- https://wiki.archlinux.org/index.php/Systemd
            Last edited by bobbicat; Jun 13, 2015, 04:10 AM.

            Comment


              #21
              Good news!! Shutdown scripts were fixed in Plasma 5.3.2
              https://dot.kde.org/2015/06/30/plasm...utdown-scripts
              I do not personally use Kubuntu, but I'm the tech support for my daughter who does.

              Comment

              Working...
              X