![]() This way you can see a summary of the backup process at the beginning of the logfile, including the runtime of the backup folders and the update of the summary after the script is finished: #!/bin/bash So far so clear, but to make the log output more readable, I split the log lines into variables. Head -n 2000 /var/log/rsync.txt`" > /var/log/rsync.txt Rsync -av -delete $1/ /backup$1 -exclude. On this occasion I split the one-liner with "\" at the end of the line into several lines: #!/bin/bash Trash* -stats | sed '0,/^$/d'` finished \n`date ' %Y%m%d %H%M'` \n\n`head -n 2000 /var/log/rsync.log`" > /var/log/rsync.logĪfter I also copy the command line multiple times with this variant, it can be swapped out into a function. Printf "`date ' %Y%m%d %H%M'` $FOLDER `rsync -av -delete $FOLDER/ /backup$FOLDER -exclude. So that I don't have to change the folder names in each line several times, these can be replaced with variables: #!/bin/bash The -stats parameter allows to write a summary of the sync operation to a log file head -n 2000 limits the logfile to 2000 lines and writes new entries to the beginning of the logfile via ">". Printf "`date ' %Y%m%d %H%M'` /folder4 `rsync -av -delete /folder4/ /backup/folder4 -exclude. Printf "`date ' %Y%m%d %H%M'` /folder3 `rsync -av -delete /folder3/ /backup/folder3 -exclude. Printf "`date ' %Y%m%d %H%M'` /folder2 `rsync -av -delete /folder2/ /backup/folder2 -exclude. Printf "`date ' %Y%m%d %H%M'` /folder1 `rsync -av -delete /folder1/ /backup/folder1 -exclude. To allow the status of the operation to be logged in a text file, I have adapted the lines as follows: #!/bin/bash Rsync -av -delete /folder4/ /backup/folder4 Rsync -av -delete /folder3/ /backup/folder3 ![]() Rsync -av -delete /folder2/ /backup/folder2 Rsync -av -delete /folder1/ /backup/folder1 To synchronize multiple folders via rsync, the individual folders for the sync can be written into a bash file as follows, so far so simple: #!/bin/bash ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |