Changeset 9470

Show
Ignore:
Timestamp:
04/08/10 17:17:45 (3 years ago)
Author:
mbrevda
Message:

re #4167; correct variables for remotesshuser; remove debuging and various bug fixes; create dirctory structure to ensure its existance; check for the scped backup files in the correct place so that we can delete the remote copy; delete remote directory if its empty; dont complain when doing a restore and files/folders are missing. We KNOW they will be missing as we always do a restore ALL, even if some of the files are missing; version bump

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.8/backup/bin/ampbackup.php

    r9391 r9470  
    7878if($opts['remotesshhost'] && $opts['remotesshkey']){ 
    7979  $opts['now']=$opts['remotesshhost'].'.'.$opts['now']; 
    80   $user=(isset($opts['remoteuser']) && $opts['remotesshuser']!='')?$opts['remoteuser'].'\@':''; 
     80  $user=(isset($opts['remotesshuser']) && $opts['remotesshuser']!='')?$opts['remotesshuser'].'\@':''; 
    8181  $exec='/usr/bin/ssh -o StrictHostKeyChecking=no -i '.$opts['remotesshkey'].' '.$user.$opts['remotesshhost']; 
    8282  $exec.=' \'. /etc/amportal.conf;'; 
    83   $exec.='$ASTVARLIBDIR/bin/ampbackup.php cli'; 
    84   print_r($opts); 
     83  $exec.='$ASTVARLIBDIR/bin/ampbackup.php cli '; 
    8584  foreach($opts as $key => $val){ 
    8685    switch($key){ 
     
    103102  //if the ssh completed with exit code 0, copy backup over to this server 
    104103  if($execok==0){ 
     104    mkdir($opts['budir'].'/'.$opts['name']);//ensure dir structure 
    105105    $exec='/usr/bin/scp -i '.$opts['remotesshkey'].' -c blowfish '.$user.$opts['remotesshhost'].':'.$rbudir[0].'/backups/'.$opts['name'].'/'.$opts['now'].'.tar.gz '.$opts['budir'].'/'.$opts['name']; 
    106106    exec($exec,$ret); 
    107107  } 
    108108  //if we have the backup file localy, delete it from the remote server 
    109   if(is_file($amp_conf['ASTSPOOLDIR'].'/tmp/'.$opts['now'].'.tar.gz')){ 
     109  if(is_file($opts['budir'].'/'.$opts['name'].'/'.$opts['now'].'.tar.gz')){ 
    110110    $exec='/usr/bin/ssh -o StrictHostKeyChecking=no -i '.$opts['remotesshkey'].' '.$user.$opts['remotesshhost']; 
    111     $exec.=' \'rm -f '.$rbudir[0].'/backups/'.$opts['name'].'/'.$opts['now'].'.tar.gz\''; 
     111    $exec.=' \'dir='.$rbudir[0].'/backups/'.$opts['name'].'; rm -f $dir/'.$opts['now'].'.tar.gz; if [ ! "$(ls -A $dir)" ]; then rmdir $dir; fi'\''; 
    112112    exec($exec,$ret); 
    113113  } 
    114114  if($opts['remoterestore']=='yes'){//restore to local machine if requested 
    115115    include_once($amp_conf['AMPWEBROOT'].'/admin/modules/backup/functions.inc.php'); 
    116     backup_restore_tar($opts['budir'].'/'.$opts['name'].'/'.$opts['now'].'.tar.gz', $opts['now'].'.tar.gz','ALL'); 
     116    @backup_restore_tar($opts['budir'].'/'.$opts['name'].'/'.$opts['now'].'.tar.gz', $opts['now'].'.tar.gz','ALL'); 
    117117  } 
    118118}else{//otherwise, run it localy