ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
------------
when i tried this script then it asked me for password , then i tried "--password-file" option but it is not picking password from /root/password file.
So, could some help me to find the bugs in above syntax, or tell me some method to avoid asking for password.
But i don't need to generate rsa keys with "ssh-keygen -t rsa" becz i am doing ssh with so it will create security loophole.
Originally posted by emailssent
when i tried this script then it asked me for password , then i tried "--password-file" option but it is not picking password from /root/password file.
[..snip..]
But i don't need to generate rsa keys with "ssh-keygen -t rsa" becz i am doing ssh with so it will create security loophole.
Why would key-authentication create a security hole, while having a clear-text password in a file would not?!?
I use a modified version of this script from Jason Pepas. His site seems to be down so I will just paste it all in here.
I call it via cron once a day at 1AM
Code:
00 1 * * * root /etc/backup/backup.sh
It works great, does an incremental backup everyday and a FULL backup on Sunday
first a script called backup.sh
Code:
#!/bin/sh
# jason pepas's backup script - see http://jason.pepas.com
# shell script tutorials:
# http://www.freeos.com/guides/lsst/
# http://www.linuxnewbie.org/nhf/intel...ashscript.html
# --------------------------------------------------
# set variables:
# --------------------------------------------------
directoryname=`date +%Y-%m-%d`"_"`hostname`"_backup"
current="current_"`hostname`
fullbackuplabel="Full Backup of "`hostname`" on "`date '+%B %e, %Y'`
fullbackupname=`date +%Y-%m-%d`"_full.tar.gz"
fullbackuplogname=`date +%Y-%m-%d`"_full.log"
incrementalbackuplabel="Incremental Backup of "`hostname`" on "`date '+%B %e, %Y'`
incrementalbackupname=`date +%Y-%m-%d`"_incremental"`date +%H%M`".tar.gz"
incrementalbackuplogname=`date +%Y-%m-%d`"_incremental"`date +%H%M`".log"
# --------------------------------------------------
# functions:
# --------------------------------------------------
fullbackup()
{
# create backup directory
if test ! -e /backup/$directoryname; then
echo "Creating /backup/$directoryname directory"
mkdir /backup/$directoryname
fi
# create (or update) a shortcut called current to this directory
echo "Updating /backup/$current pointer"
rm /backup/$current
ln -s /backup/$directoryname /backup/$current
# keep track of creation date of full backup (used with incremental backups)
echo "Updating /backup/$current/lastfullbackupdate"
date>/backup/$current/lastfullbackupdate
# create backup
echo "Running tar..."
tar --create --label "$fullbackuplabel" --files-from /root/scripts/whattobackup --exclude-from /root/scripts/whatnottobackup --ignore-failed-read --absolute-names --verbose --gzip --file /backup/$current/$fullbackupname > /backup/$current/$fullbackuplogname 2>&1
gzip /backup/$current/$fullbackuplogname
echo "Done. Created /backup/$current/$fullbackupname"
echo "To view the log, type:"
echo " zcat /backup/$current/$fullbackuplogname"
}
incrementalbackup()
{
# create variable with date of last full backup
lastfullbackupdatevar=`cat /backup/$current/lastfullbackupdate`
# check for existence of incremental backup
if test -e "/backup/$current/$incrementalbackupname"; then
echo "Your last incremental backup was less than 60 seconds ago."
echo "Wait a minute and try again."
else
# create incremental backup
echo "Running tar..."
tar --create --label "$incrementalbackuplabel" --files-from /root/scripts/whattobackup --exclude-from /root/scripts/whatnottobackup --ignore-failed-read --after-date "$lastfullbackupdatevar" --absolute-names --verbose --gzip --file /backup/$current/$incrementalbackupname > /backup/$current $incrementalbackuplogname 2>&1
gzip /backup/$current/$incrementalbackuplogname
echo "Done. Created /backup/$current/$incrementalbackupname"
echo "To view the log, type:"
echo " zcat /backup/$current/$incrementalbackuplogname"
fi
}
# --------------------------------------------------
# main routine:
# --------------------------------------------------
# first get a list of all packages installed.
dpkg --get-selections > /etc/apt/selections
# clear out apt's packages
#apt-get clean
# now perform the backup.
echo "---------- Backup Script Running... ----------"
if test `date +%A` = "Sunday" && ! -e "/backup/$directoryname"; then
# if it is sunday and you havent yet done a full backup, do so
echo "Performing Weekly Full Backup..."
fullbackup;
elif test ! -e /backup/$current/*full.tar.gz; then
# if there is no current fullbackup, make one
echo "No Current Full Backup - Performing Full Backup Now..."
fullbackup;
else
# otherwise, do an incremental backup
echo "Performing Incremental Backup..."
incrementalbackup;
fi # end if statement
echo "---------- Backup Script Done ----------"
Then a what to backup file called "whattobackup".
This is just a list "ONE ITEM" per line uses wildcards and full paths of what to backup
Code:
/boot
/etc
/home
/root
/temp
/usr/local
/var
Then a what not to backup file called "whatonotbackup".
This is just a list "ONE ITEM" per line uses wildcards and full paths of what NOT to backup.
Why would key-authentication create a security hole, while having a clear-text password in a file would not?!?
becz whenever any other person would do ssh root@liveserver from backupserver then it is not going to ask password to him. So, plz help with this issue.
thank for replying cbe, but i need to implement it through rsync, if i rsync doesn't work then i will give a try to ur backup script.
But in the mean while if u have any suggestion for my 2 line script then please give.
Originally posted by emailssent
becz whenever any other person would do ssh root@liveserver from backupserver then it is not going to ask password to him. So, plz help with this issue.
No. That will only happen if that person is root at the backup server. (unless you give root's private key to the other users, which you shouldn't of course).
I was doing mistake, becz earlier i was doing ssh through root, so i thought that if
any one would do ssh then it not ask the password, but i was wrong.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.