Writing a script to rsync all directories
I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.
To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.
In other words, I want a script that will automate the following process
rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/
Where all files in the Backups/
directory are "fair game."
Any suggestions would be appreciated.
bash scripts backup rsync
add a comment |
I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.
To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.
In other words, I want a script that will automate the following process
rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/
Where all files in the Backups/
directory are "fair game."
Any suggestions would be appreciated.
bash scripts backup rsync
add a comment |
I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.
To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.
In other words, I want a script that will automate the following process
rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/
Where all files in the Backups/
directory are "fair game."
Any suggestions would be appreciated.
bash scripts backup rsync
I have a huge set of backup files, each containing a directory of Videos. Each video directory is slightly different. I would like to merge these into a single directory to conserve, as I don't really care about which backup each Video came from.
To do this, I figure that rsync would be the best tool but I'm having difficulty coming up with a nice clean script to rsync each backup's Video directory with an outside destination.
In other words, I want a script that will automate the following process
rsync -a ./Backups/Backup-x/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-y/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-z/Videos/ ./CollectedVideos/
rsync -a ./Backups/Backup-t/Videos/ ./CollectedVideos/
Where all files in the Backups/
directory are "fair game."
Any suggestions would be appreciated.
bash scripts backup rsync
bash scripts backup rsync
asked Jul 31 '14 at 1:33
neanderslobneanderslob
4211520
4211520
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
If at least one of the folders in ./Backups
contains a Video
directory,
for dir in ./Backups/*/Videos
do
if [[ -d $dir ]]
then
rsync -a $dir/* ./CollectedVideos/
fi
done
might be close to what you are looking for.
The /*
after $dir
is important to copy the files without including their directory.
add a comment |
Did using wildcards not work:?
rsync -a backup//Videos/ /
The other way is to use find and xargs:
find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
Of course, find is a very slow running command
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%2f504792%2fwriting-a-script-to-rsync-all-directories%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
If at least one of the folders in ./Backups
contains a Video
directory,
for dir in ./Backups/*/Videos
do
if [[ -d $dir ]]
then
rsync -a $dir/* ./CollectedVideos/
fi
done
might be close to what you are looking for.
The /*
after $dir
is important to copy the files without including their directory.
add a comment |
If at least one of the folders in ./Backups
contains a Video
directory,
for dir in ./Backups/*/Videos
do
if [[ -d $dir ]]
then
rsync -a $dir/* ./CollectedVideos/
fi
done
might be close to what you are looking for.
The /*
after $dir
is important to copy the files without including their directory.
add a comment |
If at least one of the folders in ./Backups
contains a Video
directory,
for dir in ./Backups/*/Videos
do
if [[ -d $dir ]]
then
rsync -a $dir/* ./CollectedVideos/
fi
done
might be close to what you are looking for.
The /*
after $dir
is important to copy the files without including their directory.
If at least one of the folders in ./Backups
contains a Video
directory,
for dir in ./Backups/*/Videos
do
if [[ -d $dir ]]
then
rsync -a $dir/* ./CollectedVideos/
fi
done
might be close to what you are looking for.
The /*
after $dir
is important to copy the files without including their directory.
edited Jul 31 '14 at 2:24
answered Jul 31 '14 at 1:53
murumuru
1
1
add a comment |
add a comment |
Did using wildcards not work:?
rsync -a backup//Videos/ /
The other way is to use find and xargs:
find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
Of course, find is a very slow running command
add a comment |
Did using wildcards not work:?
rsync -a backup//Videos/ /
The other way is to use find and xargs:
find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
Of course, find is a very slow running command
add a comment |
Did using wildcards not work:?
rsync -a backup//Videos/ /
The other way is to use find and xargs:
find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
Of course, find is a very slow running command
Did using wildcards not work:?
rsync -a backup//Videos/ /
The other way is to use find and xargs:
find backups/Backup-*/ -type f -name ""| xargs -I {} -n 1 rsync {} /
Of course, find is a very slow running command
answered Dec 9 '18 at 9:22
tpb261tpb261
101
101
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%2f504792%2fwriting-a-script-to-rsync-all-directories%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