Home › Forums › OS X Server and Client Discussion › Open Directory › Using slapconfig -backupdb in a backup script
- This topic has 3 replies, 4 voices, and was last updated 17 years, 2 months ago by
benhur.
-
AuthorPosts
-
July 9, 2007 at 6:11 pm #369464
kainewynd2
ParticipantFirst item to note: I am competent with bash scripting, but not “good.” If I was good I wouldn’t be asking this question. 🙂
So, I have a client who was only able to purchase one OD Xserve to use in a AD-OD integration project. Everything is running great (finally), but I would like to be able to pull nightly database backups since we don’t have a replica scenario in place.
So far I have the following:
[code]
############################################
# VARIABLES
############################################
DATE=`date “+%Y-%m-%d”`
BPATH=”/Volumes/Data/Backup/ODBackup”
FILENAME=”$BPATH/$DATE-backup”
PASSWORD=”blargh”############################################
# WORK
############################################
/usr/sbin/slapconfig -backupdb $FILENAME/usr/sbin/chmod 700 $FILENAME
[/code]As you can see I am missing one major portion of the code which is where I pass the archive password variable. I know this sort of thing is possible in bash scripting, but I’m not entirely sure what it’s called so I haven’t had any luck looking it up.
Additionally, I am aware of the security implications of having the archive password in a clear text document and will have permissions set accordingly.
Thanks in advance.
–Mike
July 10, 2007 at 11:39 pm #369477Dean_Shavit
Participant[QUOTE][u]Quote by: kainewynd2[/u][p]First item to note: I am competent with bash scripting, but not “good.” If I was good I wouldn’t be asking this question. 🙂
So, I have a client who was only able to purchase one OD Xserve to use in a AD-OD integration project. Everything is running great (finally), but I would like to be able to pull nightly database backups since we don’t have a replica scenario in place.
So far I have the following:
[code]
############################################
# VARIABLES
############################################
DATE=`date “+%Y-%m-%d”`
BPATH=”/Volumes/Data/Backup/ODBackup”
FILENAME=”$BPATH/$DATE-backup”
PASSWORD=”blargh”############################################
# WORK
############################################
/usr/sbin/slapconfig -backupdb $FILENAME/usr/sbin/chmod 700 $FILENAME
[/code]As you can see I am missing one major portion of the code which is where I pass the archive password variable. I know this sort of thing is possible in bash scripting, but I’m not entirely sure what it’s called so I haven’t had any luck looking it up.
Additionally, I am aware of the security implications of having the archive password in a clear text document and will have permissions set accordingly.
Thanks in advance.
–Mike[/p][/QUOTE]
That would be the “expect” command which works interactively with the current tty. Have a look at Andrina’s article on changing local admin passwords (it’s a few years old, but a good illustration on how to use expect).
August 17, 2007 at 6:26 pm #369773morgant
ParticipantFor the record, my [i]expect[/i] script is as follows (based on the suggestion [url=https://www.afp548.com/comment.php?mode=view&cid=6405]here[/url]):
[code]#!/usr/bin/expect -f
set date [timestamp -format “%Y-%m-%d”]
set archive_path “path/to/you/backup/dir”
set archive_password “password”
set archive_name “opendirectory_backup”spawn /usr/sbin/slapconfig -backupdb $archive_path/$archive_name-$date
expect “Enter archive password”
send “$archive_password\r”
expect eof[/code]Hope that helps others since I’ve not seen one like this actually posted anywhere. I really do wish the [url=https://www.afp548.com/article.php?story=20050622155757690]serveradmin method[/url] worked for me though.
[b]Edit:[/b] Of course, you really want to run put this file in root’s crontab so it runs nightly and also change the permissions to r/w/x for root-only as you’ll be storing the password right in the file.
February 11, 2008 at 11:56 pm #371465benhur
ParticipantThanks! This worked great.
-
AuthorPosts
- You must be logged in to reply to this topic.
Comments are closed