Hello guyz!
I'm new here, and this is my very first truble...
I need a script that will backup & compress the folder /media/system in the folder /media/backups
But that's not the problem, I need that only the last 7 backups (last 7 days, yeah I know, cronjob...) will stay in that folder...
The script need: 1 - Compress folder /media/system 2 - Store in /media/backups 3 - Name the compressed backup like day_month_year.tar.gzip 4 - Check the other backups and delete backups older than 7 days..
Can some one help me?
Tanks!
How about something like this......
#!/bin/bash
# This script makes a backup of the files on the primary server directory.
# Change the values of the variables to make the script work: BACKUPDIR=/data/ BACKUPFILES=*.cdf GZTARFILE=/var/tmp/data_$(date +%F).tar.gz SERVER=mcastasp1 REMOTEDIR=/home/admin/DATA_BKP LOGFILE=/home/admin/DATA_BKP/backup.log CLEANUP=/home/admin/DATA_BKP
cd $BACKUPDIR
# This creates the archive tar zcf $GZTARFILE $BACKUPFILES > /dev/null 2>&1
# Create Remote backup Directory ssh $SERVER 'mkdir -p /home/admin/DATA_BKP'
# Copy the file to another host - we have ssh keys for making this work without intervention. scp $GZTARFILE $SERVER:$REMOTEDIR > /dev/null 2>&1
# Redirect errors because this generates some if the archive # does not exist. rm $GZTARFILE 2> /dev/null
# Create a timestamp in a logfile. date >> $LOGFILE echo backup succeeded >> $LOGFILE
# Clean up remote server and leave 7 days of backup files ssh $SERVER 'find /home/admin/DATA_BKP/ -follow -name 'data_*' -ctime +7 -exec rm {} ;'
________________________________ From: Alan Hoffmeister alangtk@gmail.com To: centos@centos.org Sent: Mon, January 25, 2010 1:48:19 PM Subject: [CentOS] Bash script for backup
Hello guyz!
I'm new here, and this is my very first truble...
I need a script that will backup & compress the folder /media/system in the folder /media/backups
But that's not the problem, I need that only the last 7 backups (last 7 days, yeah I know, cronjob...) will stay in that folder...
The script need: 1 - Compress folder /media/system 2 - Store in /media/backups 3 - Name the compressed backup like day_month_year.tar.gzip 4 - Check the other backups and delete backups older than 7 days..
Can some one help me?
Tanks! _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Hi Guys,
On 25/01/10 18:56, Lennart Andersen wrote:
How about something like this......
Dont toppost! and trim the replies. Take a look at http://wiki.centos.org/GettingHelp/ListInfo for some basic guidelines that we ask everyone to follow here on the lists.
Em 25/01/2010 16:56, Lennart Andersen escreveu:
How about something like this......
#!/bin/bash
# This script makes a backup of the files on the primary server directory.
# Change the values of the variables to make the script work: BACKUPDIR=/data/ BACKUPFILES=*.cdf GZTARFILE=/var/tmp/data_$(date +%F).tar.gz SERVER=mcastasp1 REMOTEDIR=/home/admin/DATA_BKP LOGFILE=/home/admin/DATA_BKP/backup.log CLEANUP=/home/admin/DATA_BKP
cd $BACKUPDIR
# This creates the archive tar zcf $GZTARFILE $BACKUPFILES > /dev/null 2>&1
# Create Remote backup Directory ssh $SERVER 'mkdir -p /home/admin/DATA_BKP'
# Copy the file to another host - we have ssh keys for making this work without intervention. scp $GZTARFILE $SERVER:$REMOTEDIR > /dev/null 2>&1
# Redirect errors because this generates some if the archive # does not exist. rm $GZTARFILE 2> /dev/null
# Create a timestamp in a logfile. date >> $LOGFILE echo backup succeeded >> $LOGFILE
# Clean up remote server and leave 7 days of backup files ssh $SERVER 'find /home/admin/DATA_BKP/ -follow -name 'data_*' -ctime +7 -exec rm {} ;'
*From:* Alan Hoffmeister alangtk@gmail.com *To:* centos@centos.org *Sent:* Mon, January 25, 2010 1:48:19 PM *Subject:* [CentOS] Bash script for backup
Hello guyz!
I'm new here, and this is my very first truble...
I need a script that will backup & compress the folder /media/system in the folder /media/backups
But that's not the problem, I need that only the last 7 backups (last 7 days, yeah I know, cronjob...) will stay in that folder...
The script need: 1 - Compress folder /media/system 2 - Store in /media/backups 3 - Name the compressed backup like day_month_year.tar.gzip 4 - Check the other backups and delete backups older than 7 days..
Can some one help me?
Tanks!
This is what I want! But there is just one problem, I don't need SSH, I just need a folder on the local machine that will have the 7 days backup, then I'll use rsync for on remote server, but this part I already have. How can I use this script whitout the SSH?
Hi,
If you don't spent time with script you have backup-manager. I have a howto on it.
Backup manager can create backup of file svn mysql on the number of day you define and can also push those file to a another place over FTP,ssh. by default all archive are put on /var/archives.
Fabien FAYE RHCE www.generationip.com Free network tools & HOWTO for centos and Redhat
----- Mail Original ----- De: "Alan Hoffmeister" alangtk@gmail.com À: "CentOS mailing list" centos@centos.org Envoyé: Mardi 26 Janvier 2010 12:15:38 Objet: Re: [CentOS] Bash script for backup
Em 25/01/2010 16:56, Lennart Andersen escreveu:
How about something like this......
#!/bin/bash
# This script makes a backup of the files on the primary server directory.
# Change the values of the variables to make the script work: BACKUPDIR=/data/ BACKUPFILES=*.cdf GZTARFILE=/var/tmp/data_$(date +%F).tar.gz SERVER=mcastasp1 REMOTEDIR=/home/admin/DATA_BKP LOGFILE=/home/admin/DATA_BKP/backup.log CLEANUP=/home/admin/DATA_BKP
cd $BACKUPDIR
# This creates the archive tar zcf $GZTARFILE $BACKUPFILES > /dev/null 2>&1
# Create Remote backup Directory ssh $SERVER 'mkdir -p /home/admin/DATA_BKP'
# Copy the file to another host - we have ssh keys for making this work without intervention. scp $GZTARFILE $SERVER:$REMOTEDIR > /dev/null 2>&1
# Redirect errors because this generates some if the archive # does not exist. rm $GZTARFILE 2> /dev/null
# Create a timestamp in a logfile. date >> $LOGFILE echo backup succeeded >> $LOGFILE
# Clean up remote server and leave 7 days of backup files ssh $SERVER 'find /home/admin/DATA_BKP/ -follow -name 'data_*' -ctime +7 -exec rm {} ;'
From: Alan Hoffmeister alangtk@gmail.com To: centos@centos.org Sent: Mon, January 25, 2010 1:48:19 PM Subject: [CentOS] Bash script for backup
Hello guyz!
I'm new here, and this is my very first truble...
I need a script that will backup & compress the folder /media/system in the folder /media/backups
But that's not the problem, I need that only the last 7 backups (last 7 days, yeah I know, cronjob...) will stay in that folder...
The script need: 1 - Compress folder /media/system 2 - Store in /media/backups 3 - Name the compressed backup like day_month_year.tar.gzip 4 - Check the other backups and delete backups older than 7 days..
Can some one help me?
Tanks! This is what I want! But there is just one problem, I don't need SSH, I just need a folder on the local machine that will have the 7 days backup, then I'll use rsync for on remote server, but this part I already have. How can I use this script whitout the SSH?
_______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Em 26/01/2010 12:42, fabien faye escreveu:
Hi,
If you don't spent time with script you have backup-manager. I have a howto on it.
Backup manager can create backup of file svn mysql on the number of day you define and can also push those file to a another place over FTP,ssh. by default all archive are put on /var/archives.
Are you talking about this? http://www.backup-manager.org/about/ Awesome! Thanks!
Am Montag, den 25.01.2010, 19:48 +0100 schrieb Alan Hoffmeister:
Hello guyz!
I'm new here, and this is my very first truble...
I need a script that will backup & compress the folder /media/system in the folder /media/backups
But that's not the problem, I need that only the last 7 backups (last 7 days, yeah I know, cronjob...) will stay in that folder...
The script need: 1 - Compress folder /media/system 2 - Store in /media/backups 3 - Name the compressed backup like day_month_year.tar.gzip 4 - Check the other backups and delete backups older than 7 days..
Can some one help me?
Tanks!
Since it is 7 days you want putting `date +%A` in the output filename would be an easy solution. Another really simple thing is to use the --backup switch of mv.
Chris
financial.com AG
Munich head office/Hauptsitz München: Maria-Probst-Str. 19 | 80939 München | Germany Frankfurt branch office/Niederlassung Frankfurt: Messeturm | Friedrich-Ebert-Anlage 49 | 60327 Frankfurt | Germany Management board/Vorstand: Dr. Steffen Boehnert | Dr. Alexis Eisenhofer | Dr. Yann Samson | Matthias Wiederwach Supervisory board/Aufsichtsrat: Dr. Dr. Ernst zur Linden (chairman/Vorsitzender) Register court/Handelsregister: Munich – HRB 128 972 | Sales tax ID number/St.Nr.: DE205 370 553
From: Alan Hoffmeister alangtk@gmail.com
I need a script that will backup & compress the folder /media/system in the folder /media/backups But that's not the problem, I need that only the last 7 backups (last 7 days, yeah I know, cronjob...) will stay in that folder... The script need: 1 - Compress folder /media/system 2 - Store in /media/backups 3 - Name the compressed backup like day_month_year.tar.gzip 4 - Check the other backups and delete backups older than 7 days..
Either name the backups backup.`date +"%u"`. The old files will automaticaly be overwritten by the new ones... Or just after the backup, do something like (untested): find /media/backups -ctime +7 -delete
JD