Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 2 of 2

Thread: [script] Automatically backup CCcam.cfg to a FTP s

  1. #1
    Standard RSP member
    Join Date
    13 Feb 2007
    Location
    Earth
    Posts
    1,977
    Mentioned
    0 Post(s)
    Rep Power
    84

    Post [script] Automatically backup CCcam.cfg to a FTP s

    [script] Automatically backup CCcam.cfg to a FTP server

    THANKS@nl0raf

    ''
    I thank dreamboxboy1 for helping out!
    This script works on our Debian servers but you can make it work on other Linux / Unix systems also. It copy's the var/etc/ folder in to a compressed file including CCcam.cfg unless you store the file in a other location. Then it sends it to a FTP server and remove the compressed file from your server to keep things neatly.


    Requirments:
    Shell access
    Editor (Vi, Pico or Nano...)
    Cron
    ncftp (if not on your system install it [apt-get install ncftp] or use a other ftp program and edit the code)



    Step1
    Log on to your FTP server and create a folder named “backup”.

    Step 2
    Log into your CCcam server as the user you want to run this script as (usually root). You can then create a file on your server.

    # cd /etc
    # mkdir backup
    # cd backup
    # nano backup.sh


    Step 3:
    Cut and paste the script below into the file and then edit the parts required.



    #!/bin/sh
    HOST='ftp-server-IP-or-hostname'
    USER='ftp-server-username'
    PASSWD='ftp-server-password'
    DATE=`/bin/date +%Y%m%d`
    TIME=`/bin/date +%H`
    HOSTNAME=`/bin/hostname`

    tar zcvf $DATE.$TIME.$HOSTNAME.tar.gz /var/etc > /dev/null &&
    ncftpput -u $USER -p $PASSWD $HOST /backup $DATE.$TIME.$HOSTNAME.tar.gz ;:

    rm `date +%Y%m%d`.`date +%H`.$HOSTNAME.tar.gz
    It is pretty straight forward, just edit the 3 variables to make it work for you.
    Replace ftp-server-IP-or-hostname by for example 84.85.86.87 or somename.com
    Replace ftp-server-username by the username you use to log on to the FTP server
    Replace ftp-server-password by the password you use to log on to the FTP server


    Step 4:
    After you have edited and save the file you must chmod the file 755 to make it executable.

    # chmod 755 /etc/backup/backup.sh


    Step 5:
    To run the backup script automatically you need to add a line to crontab.

    # crontab -e

    To run daily enter the line



    * 0 * * /etc/backup/backup.sh

    To run weekly on Sunday @00:00hr enter the line:


    0 0 * * 0 /etc/backup/backup.sh

    To run monthly on the first day of the month @00:00hr enter the line:



    0 0 1 * * /etc/backup/backup.sh

    Your done!



    To check if the script is working:

    # cd /
    # etc/backup/backup.sh

    No errors must show. Now login to your FTP server and look for your backupfile in the folder /backup/


    Please note that this script does not remove the old files from the FTP server!
    Hope this helps you restore your server after a crash or hardware failure. ''
    Don't dream your life - live your DREAMbox ! DON'T FORGET TO SAY '' THANKS '' Note: Viewing Pay TV without a valid subscription is illegal All the files available here are kept for experimental and educational purpose only!

  2. #2
    Standard RSP member
    Join Date
    31 Dec 2007
    Posts
    33
    Mentioned
    0 Post(s)
    Rep Power
    67

    Default Script de backup pe USB

    Scripul de mai sus, modificat pentru copierea pe device USB (presupunand ca device-ul se monteaza automat pe /dev/tty0)

    File:
    backup_to_usb.sh

    Code:

    #!/bin/bash.
    DATE=`/bin/date +%Y%m%d`
    TIME=`/bin/date +%H`
    HOSTNAME=`/bin/hostname`

    cd /tmp
    echo Creating archive file ....
    sleep 2
    tar zcf $DATE.$TIME.$HOSTNAME.tar.gz /var/etc.
    echo Copy archive file to USB device ....
    sleep 2
    cp $DATE.$TIME.$HOSTNAME.tar.gz /dev/tty0.
    echo Delete the archive file from HDD ....
    sleep 2
    rm `date +%Y%m%d`.`date +%H`.$HOSTNAME.tar.gz

    Si fisierul README.TXT completat de la pasul 4:

    CODE:

    After you have edited and save the file you must chmod the file +x to make it executable.

    # chmod +x /etc/backup/backup_to_usb.sh


    Step 5:
    To run the backup script automatically you need to add a line to crontab.


    # crontab -e

    To run daily enter the line



    * 0 * * /etc/backup/backup_to_usb.sh

    To run weekly on Sunday @00:00hr enter the line:


    0 0 * * 0 /etc/backup/backup_to_usb.sh

    To run monthly on the first day of the month @00:00hr enter the line:



    0 0 1 * * /etc/backup/backup_to_usb.sh

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •