Xin chào ! Nếu đây là lần đầu tiên bạn đến với diễn đàn, xin vui lòng danh ra một phút bấm vào đây để đăng kí và tham gia thảo luận cùng VnPro.

Announcement

Collapse
No announcement yet.

Help backup svn trong centOS6

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help backup svn trong centOS6

    Dưới là đoạn shell scrip backup svn, mình đã thực hiện thành công, nhưng mình muốn khi backup nó tự động tao ra 1 thư mục của ngày hôm đó (VD: 16-04-2013) và lưu dữ liệu backup vào trong thư mục đó, mong thầy và anh em giúp đỡ.

    #!/bin/bash
    bakdate=$(date +%Y%m%d%H%M)
    echo "--------------------------------"
    echo "Running SVN backup $bakdate"
    echo "--------------------------------\n"

    # From where to backup repos?
    # ---------------------------
    svnrepos="/var/svn"
    echo "\nGoing to backup all SVN repos located at: $svnrepos \n"

    # Where to save the dump?
    # ------------------------
    bakdest="/root/backup_svn/svn"
    MAKE=`mkdir $bakdest/$bakdate`
    $MAKE
    # Location for USB drive? (to copy backup)
    # ----------------------------------------
    baktousb="/media/USB/Extra-BACKUP"

    # _________NO-COFIG-REQUIRED-BELOW-THIS-LINE___________

    # First go to SVN repo folder
    cd $svnrepos
    # Just make sure we have write access to backup-folder
    if [ -d "$bakdest" ] && [ -w "$bakdest" ] ; then
    # Now $repo has folder names = project names
    for repo in *; do
    # do svn dump for each project
    echo "Taking backup/svndump for: $repo"
    echo "Executing : svnadmin dump $repo > $bakdest/$repo-$bakdate.svn.dump \n"
    # Now finally execute the backup
    svnadmin dump $repo > $bakdest/$repo-$bakdate.svn.dump
    # You can go an extra mile by applying tar-gz compression to svn-dumps

    # We also would like to save the dump to remote place/usb
    if [ -d "$baktousb" ] && [ -w "$baktousb" ] ; then
    # USB/other directory exists, copy the dump there
    echo "Going to copy $repo dump to $baktousb directory...\n"
    cp $bakdest/$repo-$bakdate.svn.dump $baktousb
    fi
    done
    else
    echo "Unable to continue SVN backup process."
    echo "$bakdest is *NOT* a directory or you do not have write permission."
    fi


    # End of backup script
    echo "\n\n================================="
    echo " - Backup Complete, THANK YOU :-]"

  • #2
    Mình đã tìm cách giải quyết đc vấn đề rùi ah.có gì anh em tham khảo.
    #!/bin/bash
    bakdate=$(date +%d-%m-%Y)
    echo "--------------------------------"
    echo "Running SVN backup $bakdate"
    echo "--------------------------------\n"

    # From where to backup repos?
    # ---------------------------
    svnrepos="/var/svn"
    echo "\nGoing to backup all SVN repos located at: $svnrepos \n"

    # Where to save the dump?
    # ------------------------
    bakdest="/root/backup_svn"
    MAKE=`mkdir $bakdest/$bakdate`
    $MAKE
    # Location for USB drive? (to copy backup)
    # ----------------------------------------
    baktousb="/media/USB/Extra-BACKUP"

    # _________NO-COFIG-REQUIRED-BELOW-THIS-LINE___________

    # First go to SVN repo folder
    cd $svnrepos


    # Just make sure we have write access to backup-folder
    if [ -d "$bakdest" ] && [ -w "$bakdest" ] ; then
    # Now $repo has folder names = project names
    for repo in *; do
    # do svn dump for each project
    echo "Taking backup/svndump for: $repo"
    echo "Executing : svnadmin dump $repo | gzip -9 > $bakdest/$bakdate/$repo-$bakdate.svn.dump.gz \n"
    # Now finally execute the backup
    svnadmin dump $repo | gzip -9 > $bakdest/$bakdate/$repo-$bakdate.svn.dump.gz
    # You can go an extra mile by applying tar-gz compression to svn-dumps

    # We also would like to save the dump to remote place/usb
    if [ -d "$baktousb" ] && [ -w "$baktousb" ] ; then
    # USB/other directory exists, copy the dump there
    echo "Going to copy $repo dump to $baktousb directory...\n"
    cp $bakdest/$repo-$bakdate.svn.dump $baktousb
    fi
    done
    else
    echo "Unable to continue SVN backup process."
    echo "$bakdest is *NOT* a directory or you do not have write permission."
    fi


    # End of backup script
    echo "\n\n================================="
    echo " - Backup Complete, THANK YOU :-]"

    Comment


    • #3
      Cái này cũng cần thiết đó. Cảm ơn bạn.
      Last edited by lamvantu; 18-04-2013, 10:02 AM.
      Lâm Văn Tú
      Email :
      cntt08520610@gmail.com
      Viet Professionals Co. Ltd. (VnPro)
      149/1D Ung Văn Khiêm P25 Q.Bình thạnh TPHCM
      Tel: (08) 35124257 (5 lines)
      Fax (08) 35124314
      Tập tành bước đi....


      Comment


      • #4
        minh post lên rồi đó. có gì thì liên hệ qua Skype nhé, nguyen.nghi69
        mấy bạn tập trung vô mấy chổ này là đc.

        #!/bin/bash
        bakdate=$(date +%d-%m-%Y)
        echo "--------------------------------"
        echo "Running SVN backup $bakdate"
        echo "--------------------------------\n"

        # From where to backup repos?
        # ---------------------------
        svnrepos="/var/svn"
        echo "\nGoing to backup all SVN repos located at: $svnrepos \n"

        # Where to save the dump?
        # ------------------------
        bakdest="/root/backup_svn"
        MAKE=`mkdir $bakdest/$bakdate` # tự động tạo thư mục theo ngày hiện tại nè.
        $MAKE

        # Location for USB drive? (to copy backup)
        # ----------------------------------------
        baktousb="/media/USB/Extra-BACKUP"

        # _________NO-COFIG-REQUIRED-BELOW-THIS-LINE___________

        # First go to SVN repo folder
        cd $svnrepos


        # Just make sure we have write access to backup-folder
        if [ -d "$bakdest" ] && [ -w "$bakdest" ] ; then
        # Now $repo has folder names = project names
        for repo in *; do
        # do svn dump for each project
        echo "Taking backup/svndump for: $repo"
        echo "Executing : svnadmin dump $repo | gzip -9 > $bakdest/$bakdate/$repo-$bakdate.svn.dump.gz \n" # chú ý mấy cái đường dãn này nhé bạn.
        # Now finally execute the backup
        svnadmin dump $repo | gzip -9 > $bakdest/$bakdate/$repo-$bakdate.svn.dump.gz # chú ý mấy cái đường dãn này nhé bạn.
        # You can go an extra mile by applying tar-gz compression to svn-dumps

        # We also would like to save the dump to remote place/usb
        if [ -d "$baktousb" ] && [ -w "$baktousb" ] ; then
        # USB/other directory exists, copy the dump there
        echo "Going to copy $repo dump to $baktousb directory...\n"
        cp $bakdest/$repo-$bakdate.svn.dump $baktousb
        fi
        done
        else
        echo "Unable to continue SVN backup process."
        echo "$bakdest is *NOT* a directory or you do not have write permission."
        fi


        # End of backup script
        echo "\n\n================================="
        echo " - Backup Complete, THANK YOU :-]"

        Comment

        Working...
        X