View Single Post
  #156  
Old 18th April 2012, 01:49
riverman riverman is offline
Junior Member
 
Join Date: Nov 2005
Posts: 9
Thanks: 3
Thanked 0 Times in 0 Posts
Default Problem with / in date from ls

Hi,

I have problem to restore a backup. I get:

Code:
[root@ispconfig4 web6]# ~/back-res.sh dir all 2012-04-17
date: invalid date `04/'
/root/back-res.sh: line 452: [: : integer expression expected
The date command seems ok:
Code:
[root@ispconfig4 log]# date +%d
18
[root@ispconfig4 log]# date +%F
2012-04-18
[root@ispconfig4 log]# date +%Y-%m
2012-04
Code:
[root@ispconfig4 web6]# ls -ctF $BACKUPDIR
full_var-2012-04-17.tar.bz2   full_root-2012-04-17.tar.bz2   full_etc-2012-04-17.tar.bz2   full_boot-2012-04-17.tar.bz2
full_usr-2012-04-17.tar.bz2   full_lib64-2012-04-17.tar.bz2  full_home-2012-04-17.tar.bz2  2012-04/
full_sbin-2012-04-17.tar.bz2  full_lib-2012-04-17.tar.bz2    full_bin-2012-04-17.tar.bz2   log/
But the ls-command seems to leave a /-sign in the end of the date:

Code:
[root@ispconfig4 web6]# ls -ctF /bck/web6
full_var-2012-04-17.tar.bz2   full_root-2012-04-17.tar.bz2   full_etc-2012-04-17.tar.bz2   full_boot-2012-04-17.tar.bz2
full_usr-2012-04-17.tar.bz2   full_lib64-2012-04-17.tar.bz2  full_home-2012-04-17.tar.bz2  2012-04/
full_sbin-2012-04-17.tar.bz2  full_lib-2012-04-17.tar.bz2    full_bin-2012-04-17.tar.bz2   log/
Code:
[root@ispconfig4 web6]# ls -ctF /bck/web6 | grep -v ^log/
full_var-2012-04-17.tar.bz2
full_usr-2012-04-17.tar.bz2
full_sbin-2012-04-17.tar.bz2
full_root-2012-04-17.tar.bz2
full_lib64-2012-04-17.tar.bz2
full_lib-2012-04-17.tar.bz2
full_etc-2012-04-17.tar.bz2
full_home-2012-04-17.tar.bz2
full_bin-2012-04-17.tar.bz2
full_boot-2012-04-17.tar.bz2
2012-04/
Code:
[root@ispconfig4 web6]# ls -ctF /bck/web6  | grep -v ^log/ | tail -n 1
2012-04/
Code:
[root@ispconfig4 web6]# ls -ctF /bck/web6  | grep -v ^log/ | tail -n 1 | cut -d "-" -f 2
04/
The ls command ends a directory with / and therefor will the date be wrong...

Dist: Centos 6.2 64-bit

Code:
Variables section
-----------------
COMPUTER="web6"
DIRECTORIES="/bin /boot /etc /home /lib /lib64 /root
/sbin /usr /var"                    # directories to backup
EXCLUDED="/bck /tmp /dev /proc /sys /srv /media
/var/adm /var/cache /var/lib/mysql
/var/run /var/lock /lib/init/rw /var/tmp
/var/log/verlihub /var/lib/amavis /var/amavis /var/spool/postfix/p*
/var/spool/postfix/var
/var/www/clients/client2/web5/webdav/data
/var/named/chroot/proc *.pid *.lock *.lck"        # exclude those dir's and files
BACKUPDIR="/bck/$COMPUTER"                # where to store the backups
dbuser="root"                        # database user
dbpassword="password"                # database password
email="mans.aman@riverman.com"                # mail for the responsible person
TAR=`which tar`                        # name and location of tar
ARG="-cjpSPf"        #sparse                # tar arguments P = removed /.
EARG="-xjpf"                        # tar extract arguments P = removed /
tmpdir="/tmp/tmpbck"                    # temp dir for database dump and other stuff
del_en="yes"                        # Enable delete of files if used space percent > than $maxp (yes or anything else)
maxp="85"                        # Max percent of used space before start of delete
hm="2359"                        # last minute of the day = last minute of the restored backup of the day restored
Any ideas how to fix this?

/Måns
Reply With Quote