LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   General (http://www.linuxquestions.org/questions/general-10/)
-   -   Placing a backup command in the shutdown process (http://www.linuxquestions.org/questions/general-10/placing-a-backup-command-in-the-shutdown-process-690318/)

rob07mxa 12-13-2008 08:51 AM

Placing a backup command in the shutdown process
 
Hi,

I wrote a script file (based on rsync) to backup data into a usb memory stick. I intend for the backup to occur during shutdown of the system -part of it- , The computer is for home use and switched on daily for different lengths of time. The OS is Fedora 8.

Using cron is not suitable because the machine is not switched on 24/7.

With anacron I couldn't find a way to time the execution of the script just before shutdown when most of changes to the data have happened. in other words, I do not want the backup to happen after (m) minutes delay since switching on of the computer.

The intention is to make the back up part of the normal process of Fedora 8 shutdown i.e. like modified shutdown process.

Therefore, the goal is to insert the command ($ bash backup_script) in one of the files that get executed during system shutdown, so when the user click on switch off button and the process of shutdown begins, the backup command get executed at probably the start of shutdown and when it finishes, the shutdown process carry on as usual.

The question is in which file i should put the command ($ bash backup_script)?


Thanks in anticipation

rayfordj 12-13-2008 09:17 AM

you could create a backup script and place it in /etc/rc.d/init.d/ and then link to it in /etc/rc.d/rc0.d/ and /etc/rc.d/rc6.d/ so that it is called before the killall script (S00killall) so it would need to be alphabetically before killall so you could name the link something like S00a_mybackup. Then once the execution of your backup script completes the process will continue with S00killall and then either S01halt or S01reboot. This would likely be a more preferable method vs. sticking it in the halt initscript but if you must place it in the file vs. creating its own then the file you are seeking is /etc/rc.d/init.d/halt.

arunmathew1984 12-14-2008 12:35 AM

Quote:

Originally Posted by rayfordj (Post 3374176)
you could create a backup script and place it in /etc/rc.d/init.d/ and then link to it in /etc/rc.d/rc0.d/ and /etc/rc.d/rc6.d/ so that it is called before the killall script (S00killall) so it would need to be alphabetically before killall so you could name the link something like S00a_mybackup. Then once the execution of your backup script completes the process will continue with S00killall and then either S01halt or S01reboot. This would likely be a more preferable method vs. sticking it in the halt initscript but if you must place it in the file vs. creating its own then the file you are seeking is /etc/rc.d/init.d/halt.

Wow ... I dint know this is how Shutdown worked. And neither did I know you could write custom handles to your shutdown process.

Thanks for the info buddy!


LQ Rocks ...
:)

Linux Archive

rayfordj 12-14-2008 10:46 AM

wow, i did not realize how poorly written my post was...

so... so ... so ... so... so i have no idea what i was thinking when i was writing that but i should definitely have read it for clarity before posting. note to self: anytime you type so use a period instead. sheesh! ;)


Quote:

Originally Posted by arunmathew1984 (Post 3374757)
Thanks for the info buddy!

LQ Rocks ...
:)

No problem :D
I'm glad someone found some use from my post even if it was vieing for title of longest runon sentence.


All times are GMT -5. The time now is 05:28 PM.