Simple rsync incremental backup that timestamps deleted files
I use rsync as follows:
rsync -a --backup --suffix="."$(date +"%Y%m%d%H%M") source backups
to dump the whole of folder source into the folder backups, with the additional feature that if I modify some file foo in source, the old version of foo in backups will be renamed with a date suffix before the new foo is copied into backups.
This simple procedure does the job for me, only that I would like a deleted file to be renamed with the date suffix instead of being removed from backups. That is, if foo is deleted from source, then rename foo in backups with the date suffix.
I have tried to achieve this but so far no success. Any ideas?
backup rsync
add a comment |
I use rsync as follows:
rsync -a --backup --suffix="."$(date +"%Y%m%d%H%M") source backups
to dump the whole of folder source into the folder backups, with the additional feature that if I modify some file foo in source, the old version of foo in backups will be renamed with a date suffix before the new foo is copied into backups.
This simple procedure does the job for me, only that I would like a deleted file to be renamed with the date suffix instead of being removed from backups. That is, if foo is deleted from source, then rename foo in backups with the date suffix.
I have tried to achieve this but so far no success. Any ideas?
backup rsync
add a comment |
I use rsync as follows:
rsync -a --backup --suffix="."$(date +"%Y%m%d%H%M") source backups
to dump the whole of folder source into the folder backups, with the additional feature that if I modify some file foo in source, the old version of foo in backups will be renamed with a date suffix before the new foo is copied into backups.
This simple procedure does the job for me, only that I would like a deleted file to be renamed with the date suffix instead of being removed from backups. That is, if foo is deleted from source, then rename foo in backups with the date suffix.
I have tried to achieve this but so far no success. Any ideas?
backup rsync
I use rsync as follows:
rsync -a --backup --suffix="."$(date +"%Y%m%d%H%M") source backups
to dump the whole of folder source into the folder backups, with the additional feature that if I modify some file foo in source, the old version of foo in backups will be renamed with a date suffix before the new foo is copied into backups.
This simple procedure does the job for me, only that I would like a deleted file to be renamed with the date suffix instead of being removed from backups. That is, if foo is deleted from source, then rename foo in backups with the date suffix.
I have tried to achieve this but so far no success. Any ideas?
backup rsync
backup rsync
asked Aug 12 '13 at 10:47
DustByteDustByte
2912514
2912514
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
For incremental rsync backup used rsnapshot tool.
Sample rsnapshot.conf
snapshot_root /backup
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
retain daily 7
retain weekly 4
verbose 2
loglevel 3
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
backup root@localhost:/etc/ localhost/
backup root@localhost:/home localhost/
backup root@localhost:/var/www/ localhost/
Set Cronjobs For auto backup:
# m h dom mon dow command
#Run Rsnapshot At 02:00 Everyday
00 02 * * * /usr/bin/rsnapshot daily
#Run Rsnapshot At 06:00 Every Sunday
00 06 * * 0 /usr/bin/rsnapshot weekly
At this stage I am looking for a simple, preferably one-line, rsync solution. If it does not exist, then I will perhaps (some time in the future) resort to more involved methods.
– DustByte
Aug 12 '13 at 11:34
You can try following command once you delete source its rename files as per your requirements :) rsync -a --delete --backup --suffix="."$(date +"%Y%m%d%H%M") source/ dest/
– Mitesh Shah
Aug 12 '13 at 11:39
Unfortunately the--deleteoption does not work. If you keep modifying a file, say foo, time stamps will repeatedly be added to previous time stamps, e.g. foo.201308121241.201308121242.201308121243 will eventually appear in backups.
– DustByte
Aug 12 '13 at 11:45
add a comment |
Adding the --backup-dir option should do what you're looking for:
--backup-dir=DIR
In combination with the --backup option, this tells rsync to store all backups in the specified directory on the receiving side. This can be used for incremental backups. You can additionally specify a backup suffix using the --suffix option (otherwise the files backed up in the specified directory will keep their original filenames).
e.g.
rsync -ab --backup-dir=versions --suffix="."$(date +"%Y%m%d%H%M") --delete /source/folder/ /destination/folder
This would create backups of your files at /destination/versions
Source: https://linux.die.net/man/1/rsync
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%2f331607%2fsimple-rsync-incremental-backup-that-timestamps-deleted-files%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
For incremental rsync backup used rsnapshot tool.
Sample rsnapshot.conf
snapshot_root /backup
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
retain daily 7
retain weekly 4
verbose 2
loglevel 3
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
backup root@localhost:/etc/ localhost/
backup root@localhost:/home localhost/
backup root@localhost:/var/www/ localhost/
Set Cronjobs For auto backup:
# m h dom mon dow command
#Run Rsnapshot At 02:00 Everyday
00 02 * * * /usr/bin/rsnapshot daily
#Run Rsnapshot At 06:00 Every Sunday
00 06 * * 0 /usr/bin/rsnapshot weekly
At this stage I am looking for a simple, preferably one-line, rsync solution. If it does not exist, then I will perhaps (some time in the future) resort to more involved methods.
– DustByte
Aug 12 '13 at 11:34
You can try following command once you delete source its rename files as per your requirements :) rsync -a --delete --backup --suffix="."$(date +"%Y%m%d%H%M") source/ dest/
– Mitesh Shah
Aug 12 '13 at 11:39
Unfortunately the--deleteoption does not work. If you keep modifying a file, say foo, time stamps will repeatedly be added to previous time stamps, e.g. foo.201308121241.201308121242.201308121243 will eventually appear in backups.
– DustByte
Aug 12 '13 at 11:45
add a comment |
For incremental rsync backup used rsnapshot tool.
Sample rsnapshot.conf
snapshot_root /backup
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
retain daily 7
retain weekly 4
verbose 2
loglevel 3
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
backup root@localhost:/etc/ localhost/
backup root@localhost:/home localhost/
backup root@localhost:/var/www/ localhost/
Set Cronjobs For auto backup:
# m h dom mon dow command
#Run Rsnapshot At 02:00 Everyday
00 02 * * * /usr/bin/rsnapshot daily
#Run Rsnapshot At 06:00 Every Sunday
00 06 * * 0 /usr/bin/rsnapshot weekly
At this stage I am looking for a simple, preferably one-line, rsync solution. If it does not exist, then I will perhaps (some time in the future) resort to more involved methods.
– DustByte
Aug 12 '13 at 11:34
You can try following command once you delete source its rename files as per your requirements :) rsync -a --delete --backup --suffix="."$(date +"%Y%m%d%H%M") source/ dest/
– Mitesh Shah
Aug 12 '13 at 11:39
Unfortunately the--deleteoption does not work. If you keep modifying a file, say foo, time stamps will repeatedly be added to previous time stamps, e.g. foo.201308121241.201308121242.201308121243 will eventually appear in backups.
– DustByte
Aug 12 '13 at 11:45
add a comment |
For incremental rsync backup used rsnapshot tool.
Sample rsnapshot.conf
snapshot_root /backup
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
retain daily 7
retain weekly 4
verbose 2
loglevel 3
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
backup root@localhost:/etc/ localhost/
backup root@localhost:/home localhost/
backup root@localhost:/var/www/ localhost/
Set Cronjobs For auto backup:
# m h dom mon dow command
#Run Rsnapshot At 02:00 Everyday
00 02 * * * /usr/bin/rsnapshot daily
#Run Rsnapshot At 06:00 Every Sunday
00 06 * * 0 /usr/bin/rsnapshot weekly
For incremental rsync backup used rsnapshot tool.
Sample rsnapshot.conf
snapshot_root /backup
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
cmd_du /usr/bin/du
cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
retain daily 7
retain weekly 4
verbose 2
loglevel 3
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
backup root@localhost:/etc/ localhost/
backup root@localhost:/home localhost/
backup root@localhost:/var/www/ localhost/
Set Cronjobs For auto backup:
# m h dom mon dow command
#Run Rsnapshot At 02:00 Everyday
00 02 * * * /usr/bin/rsnapshot daily
#Run Rsnapshot At 06:00 Every Sunday
00 06 * * 0 /usr/bin/rsnapshot weekly
answered Aug 12 '13 at 10:58
Mitesh ShahMitesh Shah
40429
40429
At this stage I am looking for a simple, preferably one-line, rsync solution. If it does not exist, then I will perhaps (some time in the future) resort to more involved methods.
– DustByte
Aug 12 '13 at 11:34
You can try following command once you delete source its rename files as per your requirements :) rsync -a --delete --backup --suffix="."$(date +"%Y%m%d%H%M") source/ dest/
– Mitesh Shah
Aug 12 '13 at 11:39
Unfortunately the--deleteoption does not work. If you keep modifying a file, say foo, time stamps will repeatedly be added to previous time stamps, e.g. foo.201308121241.201308121242.201308121243 will eventually appear in backups.
– DustByte
Aug 12 '13 at 11:45
add a comment |
At this stage I am looking for a simple, preferably one-line, rsync solution. If it does not exist, then I will perhaps (some time in the future) resort to more involved methods.
– DustByte
Aug 12 '13 at 11:34
You can try following command once you delete source its rename files as per your requirements :) rsync -a --delete --backup --suffix="."$(date +"%Y%m%d%H%M") source/ dest/
– Mitesh Shah
Aug 12 '13 at 11:39
Unfortunately the--deleteoption does not work. If you keep modifying a file, say foo, time stamps will repeatedly be added to previous time stamps, e.g. foo.201308121241.201308121242.201308121243 will eventually appear in backups.
– DustByte
Aug 12 '13 at 11:45
At this stage I am looking for a simple, preferably one-line, rsync solution. If it does not exist, then I will perhaps (some time in the future) resort to more involved methods.
– DustByte
Aug 12 '13 at 11:34
At this stage I am looking for a simple, preferably one-line, rsync solution. If it does not exist, then I will perhaps (some time in the future) resort to more involved methods.
– DustByte
Aug 12 '13 at 11:34
You can try following command once you delete source its rename files as per your requirements :) rsync -a --delete --backup --suffix="."$(date +"%Y%m%d%H%M") source/ dest/
– Mitesh Shah
Aug 12 '13 at 11:39
You can try following command once you delete source its rename files as per your requirements :) rsync -a --delete --backup --suffix="."$(date +"%Y%m%d%H%M") source/ dest/
– Mitesh Shah
Aug 12 '13 at 11:39
Unfortunately the
--delete option does not work. If you keep modifying a file, say foo, time stamps will repeatedly be added to previous time stamps, e.g. foo.201308121241.201308121242.201308121243 will eventually appear in backups.– DustByte
Aug 12 '13 at 11:45
Unfortunately the
--delete option does not work. If you keep modifying a file, say foo, time stamps will repeatedly be added to previous time stamps, e.g. foo.201308121241.201308121242.201308121243 will eventually appear in backups.– DustByte
Aug 12 '13 at 11:45
add a comment |
Adding the --backup-dir option should do what you're looking for:
--backup-dir=DIR
In combination with the --backup option, this tells rsync to store all backups in the specified directory on the receiving side. This can be used for incremental backups. You can additionally specify a backup suffix using the --suffix option (otherwise the files backed up in the specified directory will keep their original filenames).
e.g.
rsync -ab --backup-dir=versions --suffix="."$(date +"%Y%m%d%H%M") --delete /source/folder/ /destination/folder
This would create backups of your files at /destination/versions
Source: https://linux.die.net/man/1/rsync
add a comment |
Adding the --backup-dir option should do what you're looking for:
--backup-dir=DIR
In combination with the --backup option, this tells rsync to store all backups in the specified directory on the receiving side. This can be used for incremental backups. You can additionally specify a backup suffix using the --suffix option (otherwise the files backed up in the specified directory will keep their original filenames).
e.g.
rsync -ab --backup-dir=versions --suffix="."$(date +"%Y%m%d%H%M") --delete /source/folder/ /destination/folder
This would create backups of your files at /destination/versions
Source: https://linux.die.net/man/1/rsync
add a comment |
Adding the --backup-dir option should do what you're looking for:
--backup-dir=DIR
In combination with the --backup option, this tells rsync to store all backups in the specified directory on the receiving side. This can be used for incremental backups. You can additionally specify a backup suffix using the --suffix option (otherwise the files backed up in the specified directory will keep their original filenames).
e.g.
rsync -ab --backup-dir=versions --suffix="."$(date +"%Y%m%d%H%M") --delete /source/folder/ /destination/folder
This would create backups of your files at /destination/versions
Source: https://linux.die.net/man/1/rsync
Adding the --backup-dir option should do what you're looking for:
--backup-dir=DIR
In combination with the --backup option, this tells rsync to store all backups in the specified directory on the receiving side. This can be used for incremental backups. You can additionally specify a backup suffix using the --suffix option (otherwise the files backed up in the specified directory will keep their original filenames).
e.g.
rsync -ab --backup-dir=versions --suffix="."$(date +"%Y%m%d%H%M") --delete /source/folder/ /destination/folder
This would create backups of your files at /destination/versions
Source: https://linux.die.net/man/1/rsync
answered Jan 10 at 21:54
Alexandru UngureanuAlexandru Ungureanu
11
11
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%2f331607%2fsimple-rsync-incremental-backup-that-timestamps-deleted-files%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