Script to copy User home folders to mounted windows share


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to copy User home folders to mounted windows share
# 1  
Old 03-29-2011
Script to copy User home folders to mounted windows share

First of all, let me state that I am a windows admin.

I have a windows share mounted to /mnt/server

I need a script that will either login as sudo or perform commands with sudo rights. I need the script to copy all of the users /home folders to the mounted windows share. Now If I can schedule this script somehow, I will need the script to either, only copy the changes or overwrite the old folder each time the script is run.

I am using Fedora 10. THe type os script does not matter to me, but I do know the server runs bash.

I could create this script easily within windows, but since I need to involve linux, I am not comfortable with the syntax of linux scripts.

Thank you in advance for any help.
Eric
# 2  
Old 03-29-2011
There are man pages on rsync which automates this sort of thing, cp and cpio -p. If the volume is small, and no versioning/save newest is desired, you can just cp:
Code:
cd /home
cp -rp * /mnt/server

One issue is how to handle links and symbolic links -- some tools can move the links, other make copies of the target files or subtrees. Another idea is to zip each user's data over to there. Not only is there less space used, less data flows over the net and there is less delay creating and traversing remote directories. Windows can traverse the zip like a dir., lately!
# 3  
Old 03-29-2011
I did a:
Code:
Sudo CP -r /home/* /mnt/share

this seems to be working. How easy is it to make a script from this command?

Also I see there is a -u switch to copy only changed or new files..would that be:
Code:
sudo CP -u -r /home/* /mnt/share


Last edited by Franklin52; 03-30-2011 at 03:22 AM.. Reason: Please use code tags
# 4  
Old 03-29-2011
There are many different variations on cp. I would use the u, and the p. You could even do each user in parallel, for some speedup. How many users, how much data?
# 5  
Old 03-29-2011
What I am doing is making a bit for bit copy of the users Maildir folders to a windows share so that I can get those folders backed up onto the nightly tape.

there is maybe 40 users and I am thinking 100GB or so, I will be able to tell you better on the size after this first copy is done.
# 6  
Old 03-30-2011
If you have 100G more or less you should use rsync, much more faster then cp, and with the stats option you can see if there was something that he didn't copy.

try something like this :
Code:
rsync --verbose --relative --recursive --update --delete --perms --owner --group \
--times --links --safe-links --super --compress --one-file-system --devices $source $dest

# 7  
Old 03-30-2011
Ok, the copy finished and the main issue I see is that all of the files in each users Maildir folder are 0kb, so I think that these are links and the actual email files are stored elsewhere (not sure where).
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Copy to Windows hidden share

Hi, I need to find a solution for backing up/transferring BACKUP (dump file) from AIX (specifically) to Windows 2012 Hidden Share. The vendor says that he cannot do a copy from his system to hidden share because it requires a password... Personally, I think that there should be a solution... (9 Replies)
Discussion started by: pob579
9 Replies

2. UNIX for Dummies Questions & Answers

Unable to write to a mounted NFS share

Hi All, I created a nfs share in the server(Solaris 10) with the following command and also updated the dfstab file share -F nfs -o rw=server_name2,anon=0 /to_share And then in the client(solaris 10) added the following command to mount the share mount -F nfs server_name1:/to_share... (4 Replies)
Discussion started by: Rossdba
4 Replies

3. Shell Programming and Scripting

ftp script to copy folders recursively

hi all I want a script that will use ftp to copy folder and sub folders from source server to current server. if i use -r switch then it just copies folders for 5 level. (1 Reply)
Discussion started by: kashif.live
1 Replies

4. AIX

I/O speed to CIFS mounted Windows Share

I have an AIX box that mounts a Windows share across subnets. When I try to copy a 100 MB file to it, it copies around 2 MB/s. If I copy to another Windows share on the same subnet it copies around 12 MB/s. All I have is gigabit networks so I would expect it to go well over 12 MB/s, which is the... (8 Replies)
Discussion started by: kah00na
8 Replies

5. UNIX for Dummies Questions & Answers

Mounting a standard user, windows share at login

I know how to mount my share via /etc/fstab automatically when the system boots but since I do not have root permission to access the /etc/fstab nor do I think that the system admin wants me to add an entry in /etc/fstab all together. So what file could I add my mount entry in? mount -t cifs... (8 Replies)
Discussion started by: metallica1973
8 Replies

6. HP-UX

user can't write on cifs share but OK with Windows Explorer

Share ServerA ==== The Samba server is running on Samba version 3.0.22 based HP CIFS Server A.02.03.04 /opt/cifsclient/sbin/cifsclientd version: HP CIFS Client - Version A.02.02.02 smb file: My previous casw was thew user wasn't able to write to the share from Windows... (1 Reply)
Discussion started by: lamoul
1 Replies

7. Windows & DOS: Issues & Discussions

Windows mass copy files with same name in differnt folders

I have files existing with same names in the folders with date as display below c:\2010-09-10 <==== folder arr1.jpg arr2.jpg arr3.jpg arr4.jpg c:\2010-09-09 <==== folder arr1.jpg arr2.jpg c:\2010-09-08 <==== folder arr2.jpg arr3.jpg arr4.jpg ... (5 Replies)
Discussion started by: jville
5 Replies

8. Shell Programming and Scripting

copy some files from users home folders to my folder

i have users home directories in /home all the users have some files starting with character e and i want to copy all these files in a folder in my (root) home using a script i tried the script for i in m5 do cd m5 cp e1* /home/pc/exam cd .. done but get these... (3 Replies)
Discussion started by: pcrana
3 Replies

9. Windows & DOS: Issues & Discussions

Copy folders and subfolders from unix to windows

Sir From a unix machine some folders and their folders have to be copied to windows XP PC. Please help me with a batch file or a shell script. I am new to the the shell and batch files. Thanks in anticipation. sastry (3 Replies)
Discussion started by: chssastry
3 Replies

10. Solaris

Copy Folders from Sun Solaris to Windows server.

Hi, I have a folder with diff subfolders in my Unix box and now I want to ftp all the floders into my Windows machine. Is there any easy way to do that. When I use the "mget " cmd and try to FTP the files, it throws an error that the sub folder name does not exist. Can you someone help in... (3 Replies)
Discussion started by: chandu_kalari
3 Replies
Login or Register to Ask a Question