nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Shell code for Restoring cpmove accounts(bulk amount)

This is a discussion on Shell code for Restoring cpmove accounts(bulk amount) within the Shell scripting forums, part of the Development/Scripting category; Hello My server's hard disk is going to replace tomorrow. I need this script very urgently. I have all account's ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 12-03-2007, 08:44 PM
Junior Member
User
 
Join Date: Sep 2007
My distro: CentOS
Posts: 12
Rep Power: 0
vivekv is on a distinguished road
Default Shell code for Restoring cpmove accounts(bulk amount)

Hello

My server's hard disk is going to replace tomorrow. I need this script very urgently. I have all account's backup as

Code:
username.tar.gz
generated by the cPanel/WHM backup function

I moved these files into another server using rsync and scp..

When I get the new hard disk with new OS installation, I need to restore these files very quickly. I know there is a function in whm for restoring files. but the total number of accounts are about 600+

So I can not do this way.
I know that this way I can restore accounts using ssh


Code:
/scripts/restorepkg username

So, I need to get a code for collecting all the usernames from the file "username.tar.gz" and applying this function as a loop

Urgently required.
Please help me

Thank you
Vivek
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-03-2007, 09:36 PM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 578
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

You may need to run something as follows (assuing that you have resored /var/cpanel/user:
On main server (to backup)
Code:
for i in $(ls /var/cpanel/users)
do
 /scripts/pkgacct $i
done
Restore on another server (again assuming that you have updated file):
Code:
for i in $(ls /var/cpanel/users)
 do
  /scripts/restorepkg $i
 done
Do you have username.tar.gz for each user? or is it one file only? If you have username.tar.gz for each user, type:
Code:
for f in *.tar.gz; 
do  
  u=$(echo $f| cut -d'.' -f1); 
 /scripts/restorepkg $u ; 
done
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat

Last edited by rockdalinux; 12-03-2007 at 09:39 PM.
Reply With Quote
  #3 (permalink)  
Old 12-03-2007, 09:56 PM
Junior Member
User
 
Join Date: Sep 2007
My distro: CentOS
Posts: 12
Rep Power: 0
vivekv is on a distinguished road
Default

Code:
 #!/bin/bash
for f in *.tar.gz; 
do  
  u=$(echo $f| cut -d'.' -f1); 
 /scripts/restorepkg $u ; 
done
Thank you very much for this code. It saved my many hours of manwork!

Thank you very much
Vivek




Quote:
Originally Posted by rockdalinux View Post
You may need to run something as follows (assuing that you have resored /var/cpanel/user:
On main server (to backup)
Code:
for i in $(ls /var/cpanel/users)
do
 /scripts/pkgacct $i
done
Restore on another server (again assuming that you have updated file):
Code:
for i in $(ls /var/cpanel/users)
 do
  /scripts/restorepkg $i
 done
Do you have username.tar.gz for each user? or is it one file only? If you have username.tar.gz for each user, type:
Code:
for f in *.tar.gz; 
do  
  u=$(echo $f| cut -d'.' -f1); 
 /scripts/restorepkg $u ; 
done
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Adding Users in Bulk + Passwords and permissions ricksd2sd Shell scripting 0 04-23-2008 12:20 PM
PHP code performance zafar466 Linux software 1 04-22-2007 08:23 PM
Shell script or code for deleting a user narasimha.reddygnv Shell scripting 5 03-19-2007 10:07 AM
OpenSolaris Code Released monk The Hangout 1 06-21-2005 03:10 PM
SNMP error CODE MRTG Mediocre Linux software 3 03-18-2005 01:05 PM


All times are GMT +5.5. The time now is 05:43 AM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36