Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Member
    Join Date
    Jan 2008
    Posts
    10

    Default Manually creating tar.gz files from shell

    I want to be able to login to my server as root (via SSH), and run a command to backup a particular client's home folder (without having to go into cpanel). The reason being is that I want to backup several different clients, but don't want to have to keep switching back and forth to cpanel's "full backup" page.

    FYI: I do not have cpbackup enabled on my server.

    I was going to try something like tar -zcvf file.tar.gz /home/client
    But the resulting file is actually a different size than if I do the same backup via cpanel's full backup link (on the cpanel Web page).

    I don't know a lot about tar, etc... is that not the correct method?
    I need to know that if I restore the backups (via cpanel restore) that permissions will be ok, etc.

    Basically, I would love to know exactly how cpanel creates the backup files so I can do it via shell.

    Thanks,
    Jim.

  2. #2
    Member
    Join Date
    Mar 2006
    Posts
    1,215

    Default

    Your manual backup does not contain the users mysql and other files needed for restoring a full backup.

    Is there any reason you are not wanting to run the cpanel backup? Its a difficult task to manually create a script that does what the backup does. If you are just worried about user files then the /home/client method is fine.

  3. #3
    Member
    Join Date
    Jan 2008
    Posts
    10

    Default

    I have cpanel backup disabled because my VPS runs its own backup. I am wanting to copy the individual cpanel backup (tar.gz) to keep an "active" copy locally (which I burn to DVD). If my only solution is to login to cpanel and do a "full backup", then I guess that's what I will have to do. I was just hoping to make it easier...

    Right now, I login to WHM, click the first account I want. I go to cpanel full backup link (copying the URL), and allow it to create the full backup. I then click the next account I want in WHM and paste the copied URL (so I don't have to go through all the cpanel pages again). It creates the tar.gz files I want. I then go to the shell and type "mv /home/client/*.gz ." to put it in the current "common" folder. Chown the tar.gz to my current user to download them under one FTP account.........

    - Jim.

  4. #4
    Member
    Join Date
    Mar 2006
    Posts
    1,215

    Default

    I see. Then I would recommend setting an ftp server at home and then use the cpanel backup to log into and create the backups to the remote ftp server, which would be your local machine.

    No wasted time downloading, going through accounts, etc etc. Nothing is stored on the server side so no excess room taken or integrated into your vz image.

    All you need to do is keep your home ftp server online during its backup schedule. If thats not convenient, then simply setup the ftp backup system as mentioned and then run /scripts/cpbackup --force and that should start the backup to the remote ftp on demand.

    Good luck..

  5. #5
    Registered User
    Join Date
    Aug 2006
    Posts
    2

    Default

    Hi,

    You can make a backup from SSH using the following command :

    /scripts/pkgacct username

    This will create a full cpmove backup of respective user account which will be stored in /home.

    You will have copy of backup as
    cpmove-username.tar.gz



    You can also restore by using following command :

    /scripts/restorepkg username

    This command will automatically restore your cpmove-username.tar.gz backup.
    Prior to restore, make sure you have the copy of backup as cpmove-username.tar.gz in /home.


    Hope this helps.

    Regards,
    Boby

  6. #6
    Member brianjking's Avatar
    Join Date
    Sep 2009
    Posts
    11

    Question Local backup via SFTP or SCP - AUTOMATED

    Quote Originally Posted by boby View Post
    Hi,

    You can make a backup from SSH using the following command :

    /scripts/pkgacct username

    This will create a full cpmove backup of respective user account which will be stored in /home.

    You will have copy of backup as
    cpmove-username.tar.gz



    You can also restore by using following command :

    /scripts/restorepkg username

    This command will automatically restore your cpmove-username.tar.gz backup.
    Prior to restore, make sure you have the copy of backup as cpmove-username.tar.gz in /home.


    Hope this helps.

    Regards,
    Boby
    Anyone have a script that does this? I'd like it to run as a crontab, backup all MySQL databases, all user accounts, and have them be restorable to cPanel, and then copied/downloaded to my local machine via SCP or SFTP so I can burn to a DVD & Store on a RAID 1 hard disk.

    Please help! Thanks!

  7. #7
    BANNED
    Join Date
    Jun 2005
    Location
    Wild Wild West
    Posts
    2,025

    Wink

    Quote Originally Posted by brianjking View Post
    Anyone have a script that does this? I'd like it to run as a crontab, backup all MySQL databases, all user accounts, and have them be restorable to cPanel, and then copied/downloaded to my local machine via SCP or SFTP so I can burn to a DVD & Store on a RAID 1 hard disk.

    Please help! Thanks!
    If I understand you correctly, you want to extend the pkgacct functions
    to be able to backup all accounts instead of just single accounts?
    Code:
    #!/bin/bash
    IFS="$"
    
    cd /home
    
    ls /var/cpanel/users | grep -v "root\|mysql\|nobody" | while read CPUSER; do
       /scripts/pkgacct ${CPUSER}
    done
    
    ##### INSERT YOUR FTP TRANSFER OR MOVE COMMANDS HERE
    FYI: The same thing can be accomplished directly from WHM if you only want to backup and FTP the backups!
    Last edited by Spiral; 09-15-2009 at 05:34 PM.

Similar Threads & Tags
Similar threads

  1. Creating a database manually
    By flycast in forum Database Discussions
    Replies: 9
    Last Post: 03-02-2011, 10:59 AM
  2. restore incremental backup from shell without tar
    By syslint in forum Data Protection
    Replies: 7
    Last Post: 09-03-2010, 05:51 PM
  3. Creating an account manually
    By mbd5882 in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-10-2006, 02:43 PM
  4. cPanel backups now creating dirs and not .tar.gz files?
    By spaceman in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 03-01-2006, 10:14 PM
  5. Manually creating new email accounts
    By TCSLEA in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 12-04-2003, 01:36 PM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube