I need to write a shell script to be scheduled to run daily to backup a directory using mercurial. I have got most of the use cases done except I can figure out a way to do automated login while the script is running.
for REPOSITORY in $@
do
cd $REPOSITORY
# commit the changes
hg commit -A -m "Commit changes `date`"
# push the changes to the remote repository
if hg push
then
logger hg push success
else
logger hg push failure
fi
done
the login prompt is displayed after the hg push command is issued.
I agree that you should configure your backup script for non-interactive logins. One way is to use SSH keys and a simpler solution is to include the password directly in the URL.
Mercurial 1.3 makes it much easier to include HTTP passwords in your configuration files. I now have a
[auth]
bb.prefix = https://bitbucket.org/mg/
bb.username = mg
bb.password = pw
section in my configuration file. This means that you can avoid storing your passwords in multiple files and only concentrate on securing one file.
In fact, I am using another new feature in order to avoid putting the password in ~/.hgrc, since I might want to show that file to others. Instead I have
%include .hgauth
in ~/.hgrc and ~/.hgauth has the above [auth] section and is readable by me alone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With