Changeset 1028


Ignore:
Timestamp:
03/03/09 02:14:32 (3 years ago)
Author:
strat.cristian@…
Message:

fixes for mirror-backup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/scripts/mirror-backup

    r1027 r1028  
    88define("IA_BACKUP_SSL_CERT", "$home_dir/.ssh/ia-backup"); 
    99 
     10function week_timestamp() { 
     11    return date("YW"); 
     12} 
     13 
    1014function check_env() { 
    1115    log_assert(is_dir(IA_BACKUP_REPO_DIR)); 
     
    1418} 
    1519 
    16 function exec_rsync($source_dir, $target_dir) { 
     20function exec_rsync($source_dir, $target_dir, $delete_extraneous=false) { 
    1721    log_print("rsync $source_dir -> $target_dir"); 
    18     $cmd = sprintf("rsync -avC --delete --rsh='ssh -p 21883 -i %s' " 
     22    $delete_arg = $delete_extraneous ? '--delete' : ''; 
     23    $cmd = sprintf("rsync -avC {$delete_arg} --rsh='ssh -p 21883 -i %s' " 
    1924            ."backup@infoarena.ro:%s %s/%s", IA_BACKUP_SSL_CERT, $source_dir, 
    2025            IA_BACKUP_REPO_DIR, $target_dir); 
     
    2328 
    2429function sync_attachments() { 
    25     $new_snapshot = backup_timestamp(); 
     30    $new_snapshot = week_timestamp(); 
    2631    if (!is_dir(IA_BACKUP_REPO_DIR."/attach")) { 
    2732        mkdir(IA_BACKUP_REPO_DIR."/attach"); 
    2833    } 
    29     $last_snapshot = exec(sprintf("ls -tr1 '%s'", 
     34    $last_snapshot = exec(sprintf("ls -1 '%s'", 
    3035            IA_BACKUP_REPO_DIR."/attach")); 
    3136    if ($last_snapshot && $last_snapshot != $new_snapshot) { 
     
    3742    } 
    3843    log_print("Syncing last snapshot"); 
    39     exec_rsync('attach-live/', "attach/$new_snapshot/"); 
     44    exec_rsync('attach-live/', "attach/$new_snapshot/", true); 
    4045} 
    4146 
Note: See TracChangeset for help on using the changeset viewer.