[K12OSN] Re: Refining the script....more help? *please?*

Frank Samuelson fws4 at cdrh.fda.gov
Mon Nov 22 17:49:03 UTC 2004


You may want to use rsync rather than cp.  rsync will
only copy items that need copying.
rsync -av fromhere tothere
use the --delete option to get rid of files that are no
longer in the original directory.

-Frank


David Trask wrote:
> The script I need hellp with is below.  My latest hurdle....this script
> works great (the first time)...if I try to run it again it pauses for
> every file to ask my if I want to overwrite it.  I'd like to be able to
> run it every now and then to copy my users files from their Windows
> profile to their home directory to preserve the data and back it up.  How
> can I run it and have it overwrite no matter what or at least have it
> replace if the file being copied is newer?  I'd hate to have to keep my
> finger on the "y" key the whole time  ;-)  Any ideas welcomed.....
> 
> !#/bin/bash
> for x in `ls /home`; do
> echo "Doing $x ..."
> mkdir /home/${x}/win-backup
> chown ${x}.Users /home/${x}/win-backup
> 
> echo "Copying /opt/samba/profiles/${x}/My\ Documents/
> /home/${x}/win-backup"
> cp -Rf  /opt/samba/profiles/${x}/My\ Documents/ /home/${x}/win-backup
> 
> echo "Copying /opt/samba/profiles/${x}/Desktop/ /home/${x}/win-backup"
> cp -Rf /opt/samba/profiles/${x}/Desktop/ /home/${x}/win-backup
> 
> echo "Copying /opt/samba/profiles/${x}/Favorites/ /home/${x}/win-backup"
> cp -Rf /opt/samba/profiles/${x}/Favorites/ /home/${x}/win-backup
> 
> chown -R ${x}.Users /home/${x}/win-backup
> 
> done
> 
> 
> David N. Trask
> Technology Teacher/Coordinator
> Vassalboro Community School
> dtrask at vcs.u52.k12.me.us
> (207)923-3100
> 
> _______________________________________________
> K12OSN mailing list
> K12OSN at redhat.com
> https://www.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
> 





More information about the K12OSN mailing list