User Tools

Site Tools


tar_and_rsync_file_exclusion

If you want to send us your comments, please do so. Thanks
More on comments


tar and rsync file exclusion

Exclusion of directories and their contents

Programaabb/cc/*
rsyncExcludedExcludedOnly contents excluded
tarExcludedNot excludedOnly contents excluded

--exclude-from

--exclude-from=excludefile.txt

Proof of concept

Exclude file

aa
bb/
cc/*
7.txt
cc.31.txt

Program

#! /bin/bash
 
sdir=/tmp/tarrsyncsource
ddir1=/tmp/tarrsycndestination1
ddir2=/tmp/tarrsycndestination2
 
mkdir $sdir $ddir $sdir/aa $sdir/bb $sdir/cc
for i in {1..40}; do
  if [[ $i -lt 10 ]]; then
    touch $sdir/$i.txt
  fi
  if [[ $i -ge 10 && $i -lt 20 ]]; then
    touch $sdir/aa/aa.$i.txt
  fi
  if [[ $i -ge 20 && $i -lt 30 ]]; then
    touch $sdir/bb/bb.$i.txt
  fi
  if [[ $i -ge 30 ]]; then
    touch $sdir/cc/cc.$i.txt
  fi
done
 
rsync -avv --exclude-from=tarrsync.exclude.txt $sdir $ddir1   # copies /tmp/tarrsyncsource into /tmp/tarrsycndestination1
rsync -avv --exclude-from=tarrsync.exclude.txt $sdir/ $ddir2  # copies only the contents of /tmp/tarrsyncsource into /tmp/tarrsycndestination2

Main subjects on this wiki: Linux, Debian, HTML, Microcontrollers, Privacy

RSS
Disclaimer
Privacy statement
Bugs statement
Cookies
Copyright © : 2014 - 2024 Webevaluation.nl and the authors
Changes reserved.

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
tar_and_rsync_file_exclusion.txt · Last modified: 07-07-2021 09:33 by wim