10 files backup rotate in crontab

for file in $(find /var/backup -name "backup*" -type f |sort -r | tail -n +10); do rm -f $file; done ; tar czf /var/backup/backup-system-$(date "+\%Y\%m\%d\%H\%M-\%N").tgz --exclude /home/dummy /etc /home /opt 2>&- && echo "system backup ok"
this command can be added to crontab so as to execute a nightly backup of directories and store only the 10 last backup files.

0
By: akiuni
2014-09-24 14:04:11

What Others Think

Any student who may need Biology Writing Services Online is free to request our writers for assistance from Biology Essay Writing Services as they are committed to helping clients when they visit Legitimate Biology Writing Services Center.
florahwilliams · 63 weeks ago
This post gave me an idea about the ten file backup rotate in the Crontab and the code related to it is a very well explain here which gives an idea about the related topic plantbasedproductss.ca thanks for sharing this post with us and looking forward to more such helpful code
Kaitlyn · 2 weeks and 5 days ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: