#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    File source path backup


    What I am trying to do is to move selected file from root into the created by me folder and then restore it back to its original location by shell script. Point is that I know how to automate the creation of a folder( if it exists - do nothing) and coping a file but I have no idea how to keep the source path of the file before its moved so I can restore it back with another script I simple don't know how to do it. I tried many web sites in order to find good answer and I couldn't find anything that I would understand.
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2012
    Location
    spaceBAR Central
    Posts
    229
    Rep Power
    42
    See example below, You could 'zip' the file and see contents with 'unzip' showing directory/filename:
    Code:
    zip /path/to/zipfilename.zip /path/to/file_to_zip
    unzip -l /path/to/zipfilename.zip

    hth
  4. #3
  5. Providing fuel for space ships
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2004
    Location
    nr Edinburgh, Scotland
    Posts
    14,382
    Rep Power
    3848
    If its a backup, then I have no idea why you would want to move the file.

    However, if you're only copying the file over, check the man page for cp and look at using the --parents switch (this will preserve the dir structure in your backup dir). For example:
    Code:
    # cp --parents /home/test/folder/files/file.log /backups
    # ls -la /backups/home/test/folder/files
    total 12
    drwxr-xr-t. 2 root root 4096 Dec  2 17:24 .
    drwxrwxrwx. 4 root root 4096 Dec  2 17:20 ..
    -rw-r--r--. 1 root root    0 Dec  2 17:20 file.log
    The No Ma'am commandments:

    1.) It is O.K. to call hooters 'knockers' and sometimes snack trays
    2.) It is wrong to be French
    3.) It is O.K. to put all bad people in a giant meat grinder
    4.) Lawyers, see rule 3
    5.) It is O.K. to drive a gas guzzler if it helps you get babes
    6.) Everyone should car pool but me
    7.) Bring back the word 'stewardesses'
    8.) Synchronized swimming is not a sport
    9.) Mud wrestling is a sport

IMN logo majestic logo threadwatch logo seochat tools logo