[K12OSN] script....or cat help Samba/LDAP

Christopher K. Johnson ckjohnson at gwi.net
Tue Jul 13 11:57:41 UTC 2004


David Trask wrote:

>Hi all,
>
>I'm trying to ge things a little smoother so that I can easily duplicate
>my Samba/LDAP set up for others.  One thing I've done is copied my config
>files to an FTP share so that I can copy them down to the new server.  The
>only problem is that the permissions get shot so I actually have to open
>them.....copy the contents of the file and paste the contents into
>(overwriting) the existing file on the new server.  What I'd like to be
>able to do is something like ...take whatever text is in file "A" and copy
>it over to file "B" and in the process overwrite anything that is
>currently in file "B".  This way I could possibly "batch" or "shell
>script" a whole bunch of files to go where they need to with all the
>changes made ahead of time.  Can this be done?  If so....how?
>  
>
Tar is your friend.  Instead of copying individual files to the ftp server, try this *as root*:

tar cvzf samba_magic.tgz /etc/samba /etc/openldap/slapd.conf ... #just list full path for files or directories you want backed up separated by spaces

Then ftp /samba_magic.tgz to your ftp server, and ftp it back onto your new server.  To restore files on new server *as root*:

cd /
tar xvzf samba_magic.tgz

All done.

Better yet just create a file with all the full pathnames of directories and files you want to back up and tell tar to use that list.  If the file containing files and directories one per line is named samba_ingredients

tar cvzf samba_magic.tgz -T samba_ingredients

Then you only need to preserve your file/dir list on the ftp server, and use the couple of tar commands to do all the hard work.

If you just want to accomplish the file overwriting try something like this:
cat A > B

Chris
-- 
-----------------------------------------------------------
   "Spend less!  Do more!  Go Open Source..." -- Dirigo.net
   Chris Johnson, RHCE #807000448202021





More information about the K12OSN mailing list