Mass file+folder+directory move

mkrouse

So we have a bunch of src files that are old and out-dated and need to be moved to our new NAS storage. (I don't know why we are keeping them).

  • Is it possible to copy all the files and folders with their directories over to the new drive?
  • The directories are not already made on the new storage drive.
  • Can a command do this or do I have to make a script?

Has anybody done something similar to this?

slm

Yes you can do this if you have a system where both the src files are accessible and the NAS. There are several ways to do this with a single command, but the tool rsync is probably the best one to go with:

$ sudo rsync -avz src /mnt/NAS/

The switches (from the rsync man page):

-a, --archive               archive mode; equals -rlptgoD (no -H,-A,-X)
-v, --verbose               increase verbosity
-z, --compress              compress file data during the transfer

So the -a switch is actually a macro for a whole bunt of switches:

-r, --recursive             recurse into directories
-l, --links                 copy symlinks as symlinks
-p, --perms                 preserve permissions
-t, --times                 preserve modification times
-g, --group                 preserve group
-o, --owner                 preserve owner (super-user only)
-D                          same as --devices --specials

Running as root

You'll want to run this as root to preserve the permissions and ownerships of the files + directories. Also this particular root user will need access to the NAS. This is sometimes not setup by default so you may need the help of an admin if you're not the one.

Before you get started

Typically you'll want to do some upfront analysis on the directories in question to see if there are any symbolic links or fifo type files. These will require additional switches to rsync so that it recreates them correctly in the target directory.

No direct mounting access to NAS

All is not lost if you can't directly mount the NAS on the same box where you have access to the src files. You can also rsync over ssh.

$ sudo rsync -avz src root@remoteserver:/mnt/NAS/.

There are more advanced options if neither of these suite your needs.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

PHP - Move a file into a different folder on the server

From Dev

batch file to move and rename folder to a relative path

From Dev

move_uploaded_file / No such file or directory in PHP

From Dev

can't move_uploaded_file to folder

From Dev

Need to move mov file to a folder - Applescripts

From Dev

Move files to folder name contained in the file name

From Dev

open file folder in the directory

From Dev

How to move 'ls' output file to a folder in unix

From Dev

Qmake Qt: Move Header file to build folder

From Dev

Move file to relative parent directory

From Dev

Move file to parent folder on FTP

From Dev

python 2.7 mass zip file extraction to target directory

From Dev

find: `./folder': No such file or directory

From Dev

Move file and rename it if exist in folder

From Dev

move_uploaded_file function save to different directory folder problem

From Dev

Makefile - Dependency file in a folder "No such file or directory"

From Dev

Need to move mov file to a folder - Applescripts

From Dev

open file folder in the directory

From Dev

Script to create folder with same name as file and move file into folder

From Dev

Move every file that is not a directory

From Dev

Batch file to move a folder into another

From Dev

I need to move everything in a directory to a folder in the same directory

From Dev

batch file to create new subfolder in folder, move file to newly created subfolder, for all folders in directory

From Dev

Move File in parent directory

From Dev

move sub folder in one directory to another directory

From Dev

Mass renaming of files in folder

From Dev

cannot move a file into other folder

From Dev

Create folder for each file name and move the file

From Dev

Command to move a file to a directory even if the directory is not present

Related Related

  1. 1

    PHP - Move a file into a different folder on the server

  2. 2

    batch file to move and rename folder to a relative path

  3. 3

    move_uploaded_file / No such file or directory in PHP

  4. 4

    can't move_uploaded_file to folder

  5. 5

    Need to move mov file to a folder - Applescripts

  6. 6

    Move files to folder name contained in the file name

  7. 7

    open file folder in the directory

  8. 8

    How to move 'ls' output file to a folder in unix

  9. 9

    Qmake Qt: Move Header file to build folder

  10. 10

    Move file to relative parent directory

  11. 11

    Move file to parent folder on FTP

  12. 12

    python 2.7 mass zip file extraction to target directory

  13. 13

    find: `./folder': No such file or directory

  14. 14

    Move file and rename it if exist in folder

  15. 15

    move_uploaded_file function save to different directory folder problem

  16. 16

    Makefile - Dependency file in a folder "No such file or directory"

  17. 17

    Need to move mov file to a folder - Applescripts

  18. 18

    open file folder in the directory

  19. 19

    Script to create folder with same name as file and move file into folder

  20. 20

    Move every file that is not a directory

  21. 21

    Batch file to move a folder into another

  22. 22

    I need to move everything in a directory to a folder in the same directory

  23. 23

    batch file to create new subfolder in folder, move file to newly created subfolder, for all folders in directory

  24. 24

    Move File in parent directory

  25. 25

    move sub folder in one directory to another directory

  26. 26

    Mass renaming of files in folder

  27. 27

    cannot move a file into other folder

  28. 28

    Create folder for each file name and move the file

  29. 29

    Command to move a file to a directory even if the directory is not present

HotTag

Archive