I have Ubuntu Server 16.04.3 and daily I am making some changes to configuration files in /etc
.
I want to synchronize these files daily and take a backup of them stored on another partition? How can I achieve this?
I have Ubuntu Server 16.04.3 and daily I am making some changes to configuration files in /etc
.
I want to synchronize these files daily and take a backup of them stored on another partition? How can I achieve this?
Probably it is an overkill solution but you can use etckeeper, and similar question is well answered here.
In short:
sudo apt install etckeeper
origin
to the etckeeper cd /etc; git remote add origin <some-git-repo>
"PUSH_REMOTE="origin"
in /etc/etckeeper/etckeeper.conf
cd /etc; git push -u origin master
And you are done. etckeeper has daily cronjob (/etc/cron.daily/etckeeper
) that will do the trick as also a trigger (cat /etc/apt/apt.conf.d/05etckeeper
) to apt-commands(apt-get, apt, aptitude) which will update on each package change. You can also invoke the commit manually by running etckeeper commit
If you want simpler solution - add a daily cron job:
cat >/etc/cron.daily/my_backup <<'EOF'
tar czf /your/backup/dir "etc_$(date +%F_%T|sed -e 's/:/-/g')" /etc
EOF
I personally suggest you not to backup on another partition on the same physical unless this is really separate SSD/HDD bought at different time/manufacturer from the one containing your /etc/ folder.
The best backup is somewhere apart form your main source of valuable information... Think of a simple fire scenarios for example.