使用rsync从特定日期复制文件夹/子目录


I am using rsync to copy folders/ subdirectories from certain date and exclude all folders which is less than 180 days old.
My Folder Structure on Server1:

   ./BradsbarIN
     ./2016-06-01
              a.jpg
              b.jpg
              c.jpg
     ./2016-06-02
            a.jpg
            b.jpg
            c.jpg.
These dates go onto 2012-01-01. I want to rsync only last 180 days folders and exclude everything below from this date(2016-03-01).

rsync -avzn --list-only --include 'BradsbarIN/' --include 'BradsbarIN/2016-06-01/***' --exclude '*' -e ssh user@server.com:/path/to/old/data/ /path/to/new/data

我只想从2016-03-01复制文件夹中的所有数据。是否可以这样做。

您可以做到这一点:

rsync -avzn 
      --list-only 
      --include 'BradsbarIN/' 
      --include 'BradsbarIN/2016-0[3-9]*/***' 
      --include 'BradsbarIN/2016-1*/***' 
      --include 'BradsbarIN/201[7-9]*/***' 
      --exclude '*' 
      -e ssh 
      user@server.com:/path/to/old/data/ 
      /path/to/new/data

我添加了规则以使其在接下来的几个月和几年中继续工作,但是您确实需要前两个现在包括规则。

最新更新