WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How to perform actions on shutdown BEFORE backup  (Read 3214 times)

Offline bapon

  • Newbie
  • *
  • Posts: 11
How to perform actions on shutdown BEFORE backup
« on: November 01, 2014, 04:50:06 AM »
Hi,

my backup (.filetool.lst) on shutdown is only configured for alsa file asound.state.
Works fine, when I run "sudo alsactl store" on a terminal before shutdown.
Doesn't work though when the "alsactl store" command is put in shutdown.sh.
On reboot: settings are lost.

Apparently my command in shutdown.sh gets run after backup.

Any ideas?

Thank you.

Offline bapon

  • Newbie
  • *
  • Posts: 11
Re: How to perform actions on shutdown BEFORE backup
« Reply #1 on: November 01, 2014, 01:58:06 PM »
Hi,

do I really have to change filelist.sh and precede it's content by the command I wish to run before backup?
As a consequence I would have to backup filelist.sh too.

Or is there a less dirty solution?

Offline netnomad

  • Hero Member
  • *****
  • Posts: 1026
Re: How to perform actions on shutdown BEFORE backup
« Reply #2 on: November 02, 2014, 01:47:45 AM »
hi bapon,

i experienced the same problem.

i want to safe the popstate.dat-files of my mail-accounts in thunderbird,
to prevent that my previously checked emails are downloaded again and again.
for this reason i want to safe these popstate.date-files at every shutdown,
that i get only new mails downloaded.

unfortunately i didn' t succeed, too.

so i also welcom every help and hint.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: How to perform actions on shutdown BEFORE backup
« Reply #3 on: November 02, 2014, 06:05:33 AM »
Hi bapon
I think you might need to insert a script ahead of the  /usr/bin/exittc  binary to run commands prior to the backup being run. Though
messing with the system commands is generally not a good idea, the simplest way is probably:

Code: [Select]
sudo mv /usr/bin/exittc /usr/bin/exittc.real
sudo editor /usr/bin/exittc

When the editor comes up, type the following and save it:
Code: [Select]
#!/bin/sh

# This script replaced  /usr/bin/exittc  which was renamed to  /usr/bin/exittc.real  so
# that these commands are run first.

sudo alsactl store
exittc.real

Make the script executable
Code: [Select]
sudo chmod 770 /usr/bin/exittc
Add the following to  /opt/filetool.lst
Code: [Select]
usr/bin/exittc
exittc.real

I have not tested this but I think it will work.

            [EDIT]: Added missing call to  exittc.real  in script.
« Last Edit: November 03, 2014, 05:22:48 AM by Rich »

Offline bapon

  • Newbie
  • *
  • Posts: 11
Re: How to perform actions on shutdown BEFORE backup
« Reply #4 on: November 02, 2014, 08:25:21 AM »
Hi Rich,

thanks for replying.
I guessed it would get dirty.

Offline bapon

  • Newbie
  • *
  • Posts: 11
Re: How to perform actions on shutdown BEFORE backup
« Reply #5 on: November 03, 2014, 01:07:43 AM »
Hi,

since I didn't have your instructions in front of me, I did it similarly:

1. Rename exittc to exittc.real
2. write new exittc as shellscript with all necessary commands in it and in the end calling exittc.real from exittc.
This worked fine.

Thanks a lot.

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11178
Re: How to perform actions on shutdown BEFORE backup
« Reply #6 on: November 03, 2014, 05:38:47 AM »
Hi bapon
Thanks for confirming it works. Your post reminded me that I left out the call to  exittc.real  at the end of the sample script which
has now been corrected.