Results 1 to 4 of 4

Thread: bash backup script problem

  1. #1
    Join Date
    Feb 2008
    Location
    Swansea
    Beans
    144
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    bash backup script problem

    On our server at work I have two scripts that run daily and monthly backups.

    Code:
    find . -type f -print0 | xargs -0 mv -t $DIRNAME
    Currently the following line moves all files from the root and all subdirectories to one directory (in this instance 'Apr_10', which basically means it moves ALL backups into ONE folder). How can I change it so it only moves files found in the root folder (not the sub folders)?

    ADDITIONAL:

    I'm in the directory I need to be in and basically I just need to move all the files that have been backed up over the month in that directory (not sub-directories) to another date indexed folder. Maybe I need another command!
    Last edited by sevenearths; May 11th, 2010 at 10:32 AM.
    There is nothing common about sense - unknown

  2. #2
    Join Date
    May 2008
    Location
    Berks, UK
    Beans
    1,387

    Re: bash backup script problem

    Looks like you need to truncate the find - I forget the parameter, but you can say 'limit the search to the current directory'.

    The next stage, you need to search based on (something like) creation date/ modification date/access date - not sure I understand the precise parameters of your problem - and then move the results into the other folder.

    Yes - I'd use a new command for that
    Derek

  3. #3
    Join Date
    May 2010
    Beans
    4

    Re: bash backup script problem

    find . -maxdepth 1 -type f -print0

    then it will only search the current directory and wont go into folders

  4. #4
    Join Date
    Feb 2008
    Location
    Swansea
    Beans
    144
    Distro
    Ubuntu 9.04 Jaunty Jackalope

    Re: bash backup script problem

    Thanks. Nice 1!

    =D>
    There is nothing common about sense - unknown

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •