Sponsored Content
Top Forums Shell Programming and Scripting Script to copy User home folders to mounted windows share Post 302509029 by DGPickett on Tuesday 29th of March 2011 04:10:44 PM
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!
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
DITTO(1)						    BSD General Commands Manual 						  DITTO(1)

NAME
ditto -- copy directory hierarchies, create and extract archives SYNOPSIS
ditto [-v] [-V] [-X] [<options>] src ... dst_directory ditto [-v] [-V] [<options>] src_file dst_file ditto -c [-z | -j | -k] [-v] [-V] [-X] [<options>] src dst_archive ditto -x [-z | -j | -k] [-v] [-V] [<options>] src_archive ... dst_directory ditto -h | --help DESCRIPTION
In its first form, ditto copies one or more source files or directories to a destination directory. If the destination directory does not exist it will be created before the first source is copied. If the destination directory already exists then the source directories are merged with the previous contents of the destination. In its second form, ditto copies a file to the supplied dst_file pathname. The next two forms reflect ditto's ability to create and extract archives. These archives can be either CPIO format (preferred for unix con- tent) or PKZip (for Windows compatibility). src_archive (and dst_archive) can be the single character '-', causing ditto to read (write) ar- chive data from stdin (or to stdout, respectively). ditto follows symbolic links provided as arguments but does not follow any links as it traverses the source or destination hierarchies. ditto overwrites existing files, symbolic links, and devices in the destination when these are copied from a source. The resulting files, links, and devices will have the same mode, access time, modification time, owner, and group as the source items from which they are copied. Pipes, sockets, and files with names beginning with .nfs or .afpDeleted will be ignored. ditto does not modify the mode, owner, group, extended attributes, or ACLs of existing directories in the destination. Files and symbolic links cannot overwrite directories or vice- versa. ditto can be used to "thin" Universal Mach-O binaries during a copy. ditto can also copy files selectively based on the contents of a BOM ("Bill of Materials") file. ditto preserves file hard links (but not directory hard links) present in the source directories and preserves setuid and setgid modes when run as the superuser. ditto will preserve resource forks and HFS meta-data information when copying unless instructed otherwise using --norsrc . Similarly, ditto will preserve extended attributes and Access Control Lists (ACLs) unless --noextattr or --noacl is passed. DITTONORSRC can be set in the environment as an alias to --norsrc --noextattr --noacl on the command line. OPTIONS
-h Print full usage. -v Print a line of output to stderr for each source directory copied. -V Print a line of output to stderr for every file, symbolic link, and device copied. -X When copying one or more source directories, do not descend into directories that have a different device ID. -c Create an archive at the destination path. The default format is CPIO, unless -k is given. CPIO archives should be stored in files with names ending in .cpio. Compressed CPIO archives should be stored in files with names ending in .cpgz. -z Create compressed CPIO archives, using gzip(1) compression. -j Create compressed CPIO archives, using bzip2(1) compression. -x Extract the archives given as source arguments. The format is assumed to be CPIO, unless -k is given. Compressed CPIO is auto- matically handled. -k Create or extract from a PKZip archive instead of the default CPIO. PKZip archives should be stored in filenames ending in .zip. --keepParent When creating an archive, embed the parent directory name src in dst_archive. --arch arch Thin Universal binaries to the specified architecture. If multiple --arch options are specified then the resulting destination file will contain each of the specified architectures (if they are present in the source file). arch should be specified as "i386", "x86_64", etc. --bom bom Copy only files, links, devices, and directories that are present in the specified BOM. --rsrc Preserve resource forks and HFS meta-data. ditto will store this data in Carbon-compatible ._ AppleDouble files on filesystems that do not natively support resource forks. As of Mac OS X 10.4, --rsrc is default behavior. --norsrc Do not preserve resource forks and HFS meta-data. If both --norsrc and --rsrc are passed, whichever is passed last will take precedence. Both options override DITTONORSRC. Unless explicitly specified, --norsrc also implies --noextattr and --noacl to match the behavior of Mac OS X 10.4. --extattr Preserve extended attributes (requires --rsrc). As of Mac OS X 10.5, --extattr is the default. --noextattr Do not preserve extended attributes (requires --norsrc). --qtn Preserve quarantine information. As of Mac OS X 10.5, --qtn is the default. --noqtn Do not preserve quarantine information. --acl Preserve Access Control Lists (ACLs). As of Mac OS X 10.5, --acl is the default. --noacl Do not preserve ACLs. --nocache Do not perform copies using the Mac OS X Unified Buffer Cache. Files read and written will not be cached, although if the file is already present in the cache, the cached information will be used. --hfsCompression When copying files or extracting content from an archive, if the destination is an HFS+ volume that supports compression, all the content will be compressed if appropriate. This is only supported on Mac OS X 10.6 or later, and is only intended to be used in installation and backup scenarios that involve system files. Since files using HFS+ compression are not readable on versions of Mac OS X earlier than 10.6, this flag should not be used when dealing with non-system files or other user-generated content that will be used on a version of Mac OS X earlier than 10.6. --nohfsCompression Do not compress files with HFS+ compression when copying or extracting content from an archive unless the content is already compressed with HFS+ compression. This flag is only supported on Mac OS X 10.6 or later. --nohfsCompression is the default. --preserveHFSCompression When copying files to an HFS+ volume that supports compression, ditto will preserve the compression of any source files that were using HFS+ compression. This flag is only supported on Mac OS X 10.6 or later. --preserveHFSCompression is the default. --nopreserveHFSCompression Do not preserve HFS+ compression when copying files that are already compressed with HFS+ compression. This is only supported on Mac OS X 10.6 or later. --sequesterRsrc When creating a PKZip archive, preserve resource forks and HFS meta-data in the subdirectory __MACOSX. PKZip extraction will automatically find these resources. --zlibCompressionLevel num Sets the compression level to use when creating a PKZip archive. The compression level can be set from 0 to 9, where 0 repre- sents no compression, and 9 represents optimal (slowest) compression. By default, ditto will use the default compression level as defined by zlib. --password When extracting a password-encrypted ZIP archive, you must specify --password to allow ditto to prompt for a password to use to extract the contents of the file. If this option is not provided, and a password-encrypted file is encountered, ditto will emit an error message. EXAMPLES
The command: ditto src_directory dst_directory copies the contents of src_directory into dst_directory, creating dst_directory if it does not already exist. The command: ditto src_directory dir/dst_directory copies the contents of src_directory into dir/dst_directory, creating dir and dst_directory if they don't already exist. The command: ditto src-1 ... src-n dst_directory copies the contents of all of the src directories into dst_directory, creating dst_directory if it does not already exist. The command: ditto --arch ppc universal_file thin_file copies the contents of universal_file into thin_file, thinning executable code to ppc-only on the fly. The command: ditto -c --norsrc Scripts -|ssh rhost ditto -x --norsrc - ./Scripts copies Scripts, skipping any resources or meta-data, to rhost. The command: pax -f archive.cpio will list the files in the CPIO archive archive.cpio. The command: pax -zf archive.cpgz will list the files in the compressed CPIO archive archive.cpgz. The command: ditto -c -k --sequesterRsrc --keepParent src_directory archive.zip will create a PKZip archive similarly to the Finder's Compress functionality. The command: unzip -l archive.zip will list the files in the PKZip archive archive.zip. ERRORS
ditto returns 0 if everything is copied, otherwise non-zero. ditto almost never gives up, preferring to report errors along the way. Diag- nostic messages will be printed to standard error. ENVIRONMENT
DITTOABORT If the environment variable DITTOABORT is set, ditto will call abort(3) if it encounters a fatal error. DITTONORSRC If DITTONORSRC is set but --rsrc, --extattr, and --acl are not specified, ditto will not preserve those additional types of meta- data. BUGS
ditto doesn't copy directories into directories in the same way as cp(1). In particular, ditto foo bar will copy the contents of foo into bar, whereas cp -r foo bar copies foo itself into bar. Though this is not a bug, some may consider this bug-like behavior. --keepParent for non-archive copies will eventually alleviate this problem. SEE ALSO
bom(5), lsbom(8), mkbom(8), cpio(1), zip(1), gzip(1), bzip2(1), tar(1). Mac OS X December 19, 2008 Mac OS X
All times are GMT -4. The time now is 09:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy