How to exclude a folder from rsync
I am trying to backup my home folder on my NAS drive. I am giving this:
rsync -Paz --exclude-from 'rsync-exclude.txt' /home/chris/ admin@192.168.1.65:LinuxHome
where rsync-exclude.txt
has this content:
/home/chris/Downloads/*
/home/chris/Downloads/
/home/chris/Downloads/*.*
and it is in the same folder I execute rsync (home folder).
However the rsync tries to copy this folder, too.
What am I doing wrong?
rsync
add a comment |
I am trying to backup my home folder on my NAS drive. I am giving this:
rsync -Paz --exclude-from 'rsync-exclude.txt' /home/chris/ admin@192.168.1.65:LinuxHome
where rsync-exclude.txt
has this content:
/home/chris/Downloads/*
/home/chris/Downloads/
/home/chris/Downloads/*.*
and it is in the same folder I execute rsync (home folder).
However the rsync tries to copy this folder, too.
What am I doing wrong?
rsync
add a comment |
I am trying to backup my home folder on my NAS drive. I am giving this:
rsync -Paz --exclude-from 'rsync-exclude.txt' /home/chris/ admin@192.168.1.65:LinuxHome
where rsync-exclude.txt
has this content:
/home/chris/Downloads/*
/home/chris/Downloads/
/home/chris/Downloads/*.*
and it is in the same folder I execute rsync (home folder).
However the rsync tries to copy this folder, too.
What am I doing wrong?
rsync
I am trying to backup my home folder on my NAS drive. I am giving this:
rsync -Paz --exclude-from 'rsync-exclude.txt' /home/chris/ admin@192.168.1.65:LinuxHome
where rsync-exclude.txt
has this content:
/home/chris/Downloads/*
/home/chris/Downloads/
/home/chris/Downloads/*.*
and it is in the same folder I execute rsync (home folder).
However the rsync tries to copy this folder, too.
What am I doing wrong?
rsync
rsync
edited Sep 22 '17 at 0:46
wjandrea
9,33842664
9,33842664
asked Sep 24 '13 at 19:03
xpantaxpanta
6362821
6362821
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You are providing absolute paths in your exclude list.
With rsync, all exclude (or include!) paths beginning with /
are are anchored to the "root of transfer".
The root of transfer in this case is /home/chris
. If you did:
rsync -Paz --exclude-from 'rsync-exclude.txt' / admin@192.168.1.65:
...then your exclusions should work (but you'd be copying everything else on that filesystem!).
But since you're just trying to sync your home directory, and there is no subdirectory of /home/chris
named "home/chris/Downloads"
, rsync
finds nothing that matches.
So try removing the /home/chris
parts from your rsync-exclude.txt
file.
Actually, you should just need a single line in the file:
/Downloads
Note that if you don't specify the leading /
, and you happen to have other directories named "Downloads"
, those would also be excluded. I'm assuming you only want to exclude your "top-level" (relative to the source directory, aka the "root of transfer") Downloads
directory, so you'll want the leading /
.
THE EASIEST WAY (to exclude only a few paths)
If you only need to exclude one directory, just do this (avoiding a separate file):
rsync -Paz --exclude /Downloads /home/chris/ admin@192.168.1.65:LinuxHome
You can also chain together --exclude
tags, like so:
rsync -Paz --exclude /Downloads --exclude '/Something Else' --exclude .hiddenFile /home/chris/ admin@192.168.1.65:LinuxHome
Note that since there's no slash, that one will exclude .hiddenFile
from any every directory it copies!
But if you have more than a few exclusions, you're better off with --exclude-from
and a file.
Note
I see that you got it right, but those new to rsync should note the slash at the end of /home/chris/
To quote the rsync
man page, "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name'."
So if you left off that trailing slash, you would end up with a directory called chris
within the target directory, containing everything from /home/chris
(except the original Downloads
directory, of course!).
add a comment |
This might be easier on the eyes, and just a note on excluding directories and syntax:
SRC='/home/username'
DST='/run/media/username/EasyStoreRT/rsync'
rsync -avrh --stats
--log-file=/home/username/log/rsync-home.log
--exclude='/username/.cache'
--exclude='/username/.local/share/Trash'
$SRC
$DST
It will exclude those directories and all files within them. For whatever reason, rysnc wasn't appending /home/username to /.cache. Only home/ would anchor itself, so I had to add /username to each excluded directory.
The man pages say, "if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname." But, that hierarchy seems to only be the first directory in the source directory. I'm using bash, version 4.4.23(1)-release.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f349613%2fhow-to-exclude-a-folder-from-rsync%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You are providing absolute paths in your exclude list.
With rsync, all exclude (or include!) paths beginning with /
are are anchored to the "root of transfer".
The root of transfer in this case is /home/chris
. If you did:
rsync -Paz --exclude-from 'rsync-exclude.txt' / admin@192.168.1.65:
...then your exclusions should work (but you'd be copying everything else on that filesystem!).
But since you're just trying to sync your home directory, and there is no subdirectory of /home/chris
named "home/chris/Downloads"
, rsync
finds nothing that matches.
So try removing the /home/chris
parts from your rsync-exclude.txt
file.
Actually, you should just need a single line in the file:
/Downloads
Note that if you don't specify the leading /
, and you happen to have other directories named "Downloads"
, those would also be excluded. I'm assuming you only want to exclude your "top-level" (relative to the source directory, aka the "root of transfer") Downloads
directory, so you'll want the leading /
.
THE EASIEST WAY (to exclude only a few paths)
If you only need to exclude one directory, just do this (avoiding a separate file):
rsync -Paz --exclude /Downloads /home/chris/ admin@192.168.1.65:LinuxHome
You can also chain together --exclude
tags, like so:
rsync -Paz --exclude /Downloads --exclude '/Something Else' --exclude .hiddenFile /home/chris/ admin@192.168.1.65:LinuxHome
Note that since there's no slash, that one will exclude .hiddenFile
from any every directory it copies!
But if you have more than a few exclusions, you're better off with --exclude-from
and a file.
Note
I see that you got it right, but those new to rsync should note the slash at the end of /home/chris/
To quote the rsync
man page, "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name'."
So if you left off that trailing slash, you would end up with a directory called chris
within the target directory, containing everything from /home/chris
(except the original Downloads
directory, of course!).
add a comment |
You are providing absolute paths in your exclude list.
With rsync, all exclude (or include!) paths beginning with /
are are anchored to the "root of transfer".
The root of transfer in this case is /home/chris
. If you did:
rsync -Paz --exclude-from 'rsync-exclude.txt' / admin@192.168.1.65:
...then your exclusions should work (but you'd be copying everything else on that filesystem!).
But since you're just trying to sync your home directory, and there is no subdirectory of /home/chris
named "home/chris/Downloads"
, rsync
finds nothing that matches.
So try removing the /home/chris
parts from your rsync-exclude.txt
file.
Actually, you should just need a single line in the file:
/Downloads
Note that if you don't specify the leading /
, and you happen to have other directories named "Downloads"
, those would also be excluded. I'm assuming you only want to exclude your "top-level" (relative to the source directory, aka the "root of transfer") Downloads
directory, so you'll want the leading /
.
THE EASIEST WAY (to exclude only a few paths)
If you only need to exclude one directory, just do this (avoiding a separate file):
rsync -Paz --exclude /Downloads /home/chris/ admin@192.168.1.65:LinuxHome
You can also chain together --exclude
tags, like so:
rsync -Paz --exclude /Downloads --exclude '/Something Else' --exclude .hiddenFile /home/chris/ admin@192.168.1.65:LinuxHome
Note that since there's no slash, that one will exclude .hiddenFile
from any every directory it copies!
But if you have more than a few exclusions, you're better off with --exclude-from
and a file.
Note
I see that you got it right, but those new to rsync should note the slash at the end of /home/chris/
To quote the rsync
man page, "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name'."
So if you left off that trailing slash, you would end up with a directory called chris
within the target directory, containing everything from /home/chris
(except the original Downloads
directory, of course!).
add a comment |
You are providing absolute paths in your exclude list.
With rsync, all exclude (or include!) paths beginning with /
are are anchored to the "root of transfer".
The root of transfer in this case is /home/chris
. If you did:
rsync -Paz --exclude-from 'rsync-exclude.txt' / admin@192.168.1.65:
...then your exclusions should work (but you'd be copying everything else on that filesystem!).
But since you're just trying to sync your home directory, and there is no subdirectory of /home/chris
named "home/chris/Downloads"
, rsync
finds nothing that matches.
So try removing the /home/chris
parts from your rsync-exclude.txt
file.
Actually, you should just need a single line in the file:
/Downloads
Note that if you don't specify the leading /
, and you happen to have other directories named "Downloads"
, those would also be excluded. I'm assuming you only want to exclude your "top-level" (relative to the source directory, aka the "root of transfer") Downloads
directory, so you'll want the leading /
.
THE EASIEST WAY (to exclude only a few paths)
If you only need to exclude one directory, just do this (avoiding a separate file):
rsync -Paz --exclude /Downloads /home/chris/ admin@192.168.1.65:LinuxHome
You can also chain together --exclude
tags, like so:
rsync -Paz --exclude /Downloads --exclude '/Something Else' --exclude .hiddenFile /home/chris/ admin@192.168.1.65:LinuxHome
Note that since there's no slash, that one will exclude .hiddenFile
from any every directory it copies!
But if you have more than a few exclusions, you're better off with --exclude-from
and a file.
Note
I see that you got it right, but those new to rsync should note the slash at the end of /home/chris/
To quote the rsync
man page, "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name'."
So if you left off that trailing slash, you would end up with a directory called chris
within the target directory, containing everything from /home/chris
(except the original Downloads
directory, of course!).
You are providing absolute paths in your exclude list.
With rsync, all exclude (or include!) paths beginning with /
are are anchored to the "root of transfer".
The root of transfer in this case is /home/chris
. If you did:
rsync -Paz --exclude-from 'rsync-exclude.txt' / admin@192.168.1.65:
...then your exclusions should work (but you'd be copying everything else on that filesystem!).
But since you're just trying to sync your home directory, and there is no subdirectory of /home/chris
named "home/chris/Downloads"
, rsync
finds nothing that matches.
So try removing the /home/chris
parts from your rsync-exclude.txt
file.
Actually, you should just need a single line in the file:
/Downloads
Note that if you don't specify the leading /
, and you happen to have other directories named "Downloads"
, those would also be excluded. I'm assuming you only want to exclude your "top-level" (relative to the source directory, aka the "root of transfer") Downloads
directory, so you'll want the leading /
.
THE EASIEST WAY (to exclude only a few paths)
If you only need to exclude one directory, just do this (avoiding a separate file):
rsync -Paz --exclude /Downloads /home/chris/ admin@192.168.1.65:LinuxHome
You can also chain together --exclude
tags, like so:
rsync -Paz --exclude /Downloads --exclude '/Something Else' --exclude .hiddenFile /home/chris/ admin@192.168.1.65:LinuxHome
Note that since there's no slash, that one will exclude .hiddenFile
from any every directory it copies!
But if you have more than a few exclusions, you're better off with --exclude-from
and a file.
Note
I see that you got it right, but those new to rsync should note the slash at the end of /home/chris/
To quote the rsync
man page, "You can think of a trailing / on a source as meaning 'copy the contents of this directory' as opposed to 'copy the directory by name'."
So if you left off that trailing slash, you would end up with a directory called chris
within the target directory, containing everything from /home/chris
(except the original Downloads
directory, of course!).
edited Nov 6 '18 at 19:25
answered Sep 24 '13 at 19:31
LambartLambart
1,9011624
1,9011624
add a comment |
add a comment |
This might be easier on the eyes, and just a note on excluding directories and syntax:
SRC='/home/username'
DST='/run/media/username/EasyStoreRT/rsync'
rsync -avrh --stats
--log-file=/home/username/log/rsync-home.log
--exclude='/username/.cache'
--exclude='/username/.local/share/Trash'
$SRC
$DST
It will exclude those directories and all files within them. For whatever reason, rysnc wasn't appending /home/username to /.cache. Only home/ would anchor itself, so I had to add /username to each excluded directory.
The man pages say, "if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname." But, that hierarchy seems to only be the first directory in the source directory. I'm using bash, version 4.4.23(1)-release.
add a comment |
This might be easier on the eyes, and just a note on excluding directories and syntax:
SRC='/home/username'
DST='/run/media/username/EasyStoreRT/rsync'
rsync -avrh --stats
--log-file=/home/username/log/rsync-home.log
--exclude='/username/.cache'
--exclude='/username/.local/share/Trash'
$SRC
$DST
It will exclude those directories and all files within them. For whatever reason, rysnc wasn't appending /home/username to /.cache. Only home/ would anchor itself, so I had to add /username to each excluded directory.
The man pages say, "if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname." But, that hierarchy seems to only be the first directory in the source directory. I'm using bash, version 4.4.23(1)-release.
add a comment |
This might be easier on the eyes, and just a note on excluding directories and syntax:
SRC='/home/username'
DST='/run/media/username/EasyStoreRT/rsync'
rsync -avrh --stats
--log-file=/home/username/log/rsync-home.log
--exclude='/username/.cache'
--exclude='/username/.local/share/Trash'
$SRC
$DST
It will exclude those directories and all files within them. For whatever reason, rysnc wasn't appending /home/username to /.cache. Only home/ would anchor itself, so I had to add /username to each excluded directory.
The man pages say, "if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname." But, that hierarchy seems to only be the first directory in the source directory. I'm using bash, version 4.4.23(1)-release.
This might be easier on the eyes, and just a note on excluding directories and syntax:
SRC='/home/username'
DST='/run/media/username/EasyStoreRT/rsync'
rsync -avrh --stats
--log-file=/home/username/log/rsync-home.log
--exclude='/username/.cache'
--exclude='/username/.local/share/Trash'
$SRC
$DST
It will exclude those directories and all files within them. For whatever reason, rysnc wasn't appending /home/username to /.cache. Only home/ would anchor itself, so I had to add /username to each excluded directory.
The man pages say, "if the pattern starts with a / then it is anchored to a particular spot in the hierarchy of files, otherwise it is matched against the end of the pathname." But, that hierarchy seems to only be the first directory in the source directory. I'm using bash, version 4.4.23(1)-release.
answered Feb 11 at 23:46
jltrinchardjltrinchard
211
211
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f349613%2fhow-to-exclude-a-folder-from-rsync%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown