Save & Restore from command line

All those commands that we don't really use very often, but that we should ! Documented or not, they worth it !
Turlupin
Member
Posts: 101
Joined: 05 Jun 2007 07:59
Location: Paris / France

Re: Save & Restore from command line

Post by Turlupin »

I've just tested the command for ops backup/restoration, and it works fine :

Code: Select all

root@xa000000 root]# /DHS3bin/soft_install/bin/bck -save ops

root@xa000000 root]# /DHS3bin/soft_install/bin/bck -restore ops
You will find the backup files under : /usr4/BACKUP/OPS.
For the restoration the same directory is used.
krzysioD

Re: Save & Restore from command line

Post by krzysioD »

Moreover (see http://alcatelunleashed.com/viewtopic.php?f=1&t=2721)
if one wants to backup everything let's say 2 in the morning by IP and with encryption then (linux releases):

0 must have a routing and open port to some linux/unix host or Windows box with SSH server (default for ssh is 22)
1st create SSH DSA/RSA pair of keys (public and private)
in most cases:

Code: Select all

ssh-keygen -t rsa  -b 2048 -f $HOME/.ssh/id_rsa
then you will see (among other things):

Code: Select all

Your identification has been saved in id_rsa.
Your public key has been saved in id_rsa.pub.
[/i]
Private key files are sensitive Be sure of .ssh directory permisions! and be sure of keyfile permisions! (not even READ for Group or Others !!!)

Now transfer (with FTP or better SFTP) the PRIVATE keyfile to your unix/linux SSHD server host and put it into "authorized_keys2" file (number 2 is for SSH version).

Verify that: (on remote host:)

Code: Select all

-bash-3.2$ pwd
/home/staff/ims/hunter/.ssh
-bash-3.2$ ls -lha
total 24K
drwx------  2 hunter ims   66 Mar  1  2007 .
drwx--x--x 24 hunter ims 4.0K Aug 15  2007 ..
-r--------  1 hunter ims  607 Jul 11  2007 authorized_keys2
-rw-------  1 hunter ims 7.7K Jun 21  2007 known_hosts
Try to ssh to remote host by:

Code: Select all

ssh -C -v -2 remote.host.by.name.or.by.ip.address
It should allow you for access to your remote host WITHOUT being asked for password. If not please consult any Linux/Unix guru around or read full ssh/sshd manual.

2nd setup a script like that:

Code: Select all

#!/bin/sh

DATE=$(date +%Y_%m_%d_%H_%m)
SITE=nameofyourpabx

ssh -v -C -2 remote.host.ip "mkdir -p $HOME/backups-$SITEID/$DATE"
for i in mao acd acc vg; do
  scp -v -C -2 /usr4/BACKUP/IMMED/$i remote.host.ip:/$HOME/backups-$SITEID/$DATE/
done
Script above and proper use of bck command should allow of automatic backup over a network.

Please see that you should test this at least 2-3 times before putting into production, test the private key file seciurity (should be "r-- --- ---") and also maybe add some error checking (if scp command was executed propelly) test network connection by ping etc...
Last edited by krzysioD on 06 Mar 2008 03:23, edited 1 time in total.
Turlupin
Member
Posts: 101
Joined: 05 Jun 2007 07:59
Location: Paris / France

Re: Save & Restore from command line

Post by Turlupin »

Great nice job !

I'm writing a script to, wich will permit to change the local backup directory, export backup files directly on a ftp server(i will try with ftps later), log backup operations on local system and ftp server ...

It's nearly finished ... i'll post it in fex days !
Sorry for my english .... :)
User avatar
patmul39
Member
Posts: 417
Joined: 03 Sep 2004 11:12
Location: Wellingborough - UK

Re: Save & Restore from command line

Post by patmul39 »

Add the line (using vi command) : 0 4 * * * /DHS3bin/soft_install/bin/bck -save acd>/dev/null 2>&1
This will perform a save operations of all the acd files under /usr4/BACKUP/IMMED/ every day at 4 am
Hi Turlupin, I have managed to do an auto backup using the command as explained above. But I did notice that if I log back in to swinst to check the auto backup setting and logout, the command line is removed from crontab. I might be doing something wrong but I have tried several ways and every single time the line is removed.
Any thoughts?
Thanks.
We don't see things the way they are; we see things the way we are!
krzysioD

Re: Save & Restore from command line

Post by krzysioD »

If it's linux you could use "system" crontab for monthly/daily/weekly jobs etc, try command ls in /etc and you will see

Code: Select all

(101)xa000000> pwd
/etc
(101)xa000000> ls cron*
cron.deny  crontab

cron.d:
kmod

cron.daily:
logrotate  slocate.cron  tmpwatch

cron.hourly:
logrotate

cron.monthly:

cron.weekly:
Simpy create a /etc/con.daily/my_backup file with everything you need like:

Code: Select all

[root@xa000000 etc]# cat << EOF > /etc/cron.daily/my_backup
> #!/bin/sh
> DHS3bin/soft_install/bin/bck -save acd>/dev/null 2>&1
> EOF
[root@xa000000 etc]# chmod a+r /etc/cron.daily/my_backup
[/code]
User avatar
patmul39
Member
Posts: 417
Joined: 03 Sep 2004 11:12
Location: Wellingborough - UK

Re: Save & Restore from command line

Post by patmul39 »

Thanks for your reply krzysioD, but excuse my ignorance - I am not a linux guru so when I'm not sure of something i'll ask until i'm confident with what i'm doing.
Here's my scenario - Rel 8.0
1 - customer has no duplication on system (1 AS), silly but that's how it is.
2 - I can configure a daily backup (Swinst opt 2,4,2) but the system will only save the mao-acc
3 - I need to save: mao; acc; vg; obstraf and ACD
4 - we have a 4760 server, hence we have set this for a daily backup; 4760, if i'm not mistaken, will ftp any files the usr4/BACKUP/IMMED folder (ONLY)
hence I need to create a process that automatically saves the above files into the IMMED folder.

Thanks.
We don't see things the way they are; we see things the way we are!
krzysioD

Re: Save & Restore from command line

Post by krzysioD »

you are right (about 1-4).

IF you want to have a very good backup of account data (like you bill your customers for every penny and your PBX is some "building" PBX) you could use old tool named "RSYNC". There is a version for windows too (for example for installing on OV PC).

For accounting you need /usr4/account/TAX*.DAT files, so RSYNC them every hour or so.
torrentula

Re: Save & Restore from command line

Post by torrentula »

2 - I can configure a daily backup (Swinst opt 2,4,2) but the system will only save the mao-acc
3 - I need to save: mao; acc; vg; obstraf and ACD
4 - we have a 4760 server, hence we have set this for a daily backup; 4760, if i'm not mistaken, will ftp any files the usr4/BACKUP/IMMED folder (ONLY)
hence I need to create a process that automatically saves the above files into the IMMED folder.
If someone had a script for this that would also include vmail, I would donate my left pinky to get it :D
krzysioD

Re: Save & Restore from command line

Post by krzysioD »

What kind of voice mail huh?

Anyway:

i've tried to copy all of incoming VM (4645) to second hdd or somewhere (anywhere) and got stuck.

Instead of investing in 4645 licence i've setup a asterisk-based vm system (connected by PRA board) and it works fine (sip is too much expensive).

give us some info what vmail and we will try :)
Post Reply

Return to “Usefull commands”