LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-16-2003, 05:54 AM   #1
RaVensRealm
LQ Newbie
 
Registered: Apr 2003
Distribution: Mandrake 9.0
Posts: 3

Rep: Reputation: 0
backing up linux with a batch file...


I want to create a batch file that backs up my linux configuration. I know that to do this I need to backup the directories VAR, ROOT, ETC and HOME. Root obviously requires root privileges, but I want to be able to run the batch file without being logged in as root. So what I want is:

1) I'm logged in as myself and I want to backup VAR, ETC, HOME and ROOT directories to another local drive.
2) I run a shortcut to a batch file which will do the job.
3) When started, the program asks for the root password.

I'm hoping step 3 means that the batch program will have root privileges to be able to backup ROOT. Is my way of thinking correct?

If anyone can write a good example that I can use I would be most grateful.

Thanks for your time.

RaVensRealm
 
Old 04-16-2003, 02:20 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Create the script and save it as /root/backup.sh then run it as root with:
su - -c /root/backup.sh

This will prompt you for the root password.
 
Old 04-16-2003, 03:07 PM   #3
RaVensRealm
LQ Newbie
 
Registered: Apr 2003
Distribution: Mandrake 9.0
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks for your help. Can I create a shortcut that does "su - -c /root/backup.sh" to save typing it. If its not called a shortcut in Linux I apologise - I guess I'm having a hard time shaking off the Micro$oft upbringing. Actually shortcuts are called links in Linux aren't they?
I have observed several backup scripts on the net and I intend to make my own tailored one in due course.

BTW I like the signature - fortunately even I know what that does and I don't intend to do it - just yet.

RaVensRealm
 
Old 04-16-2003, 03:20 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 66
Yes they are called links but no you can't make a link You make a file called /usr/bin/bkup containing.
Code:
#!/bin/bash
su - -c /root/backup.sh
exit;
 
Old 04-16-2003, 04:07 PM   #5
bulliver
Senior Member
 
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86_64; Gentoo PPC; FreeBSD; OS X 10.9.4
Posts: 3,760
Blog Entries: 4

Rep: Reputation: 78
I would suggest writing your backup script, then running it as a cron job. Cron jobs may be run as root, and you can set it up to do a backup daily, weekly, or whatever, and just overwrite the old one. Check out man crond, or else I'm sure there is a cron howto at the LDP.
 
Old 04-16-2003, 09:21 PM   #6
RaVensRealm
LQ Newbie
 
Registered: Apr 2003
Distribution: Mandrake 9.0
Posts: 3

Original Poster
Rep: Reputation: 0
Smile

Thank you David_Ross and Bulliver for helping me on this. I've got a backup script working nicely. I will have a look at cron in due course.

RaVensRealm
 
Old 04-16-2003, 09:59 PM   #7
KnightAbel
Member
 
Registered: Sep 2002
Location: Kaysville, UT USA
Distribution: Red Hat Linux, Slackware
Posts: 242

Rep: Reputation: 30
you can also make the shell script owned by root and then set the permissions to suid it. This allows a program to be started by anyone, but run as the user. If you do want to do this though, you have to remember that it can create security holes.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create batch file? TigerLinux Linux - Newbie 16 09-26-2011 01:24 PM
Trigger linux command by windows batch file? mariusak Linux - Networking 6 06-03-2005 06:15 AM
How to create a batch file? Franziss Programming 8 05-16-2005 01:36 AM
call program on linux box from windows batch file naijaguy Programming 5 08-14-2004 12:12 PM
Like MS-DOS batch file but for Linux? rverlander Programming 2 06-23-2002 03:51 PM


All times are GMT -5. The time now is 12:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration