Search Posts on Binpipe Blog

SCREEN COMMAND IN LINUX

Screen: how to run processes in the background after log out

Screen can create multiple windows in a shell, from which you can "detach" and leave them running in the background, even if you log out of your user account.


Create a Screen


From a terminal, type:

$ screen -S [choose-a-window-name]

And you will immediately enter the window just created.
From this window you can type any command and leave it running in the background.

To detach from the window and go back to the terminal, just press the combination:

ctrl-a d

And you will go back to the terminal, where you can start more screens if needed, or even log out without stopping the job.


Access a previously created Screen


From a terminal, type:

$ screen -r [window-name]

to revert a previously created screen. If you do not remember the window name, you can list them through the command:

$ screen -ls

which gives information about the active screens and their names.


Kill a Screen


If your job is finished in one screen and you want to close it, you can go revert it and press:

ctrl-d

to close it, or you can close it from outside the screen through the command:

$ screen -X -S [window-name] kill

Uncompress .xz Compressed Files

Use 'tar' command to uncompress .xz compressed files

tar xvfJ filename.tar.xz

But remember, .xz formats are supported only from tar 1.22 version.

If you have a lower version of tar like me, then either you can update your tar command or download xz utilities. To update the tar command, type as shown below:

yum update tar

Note: In case, if "yum update" didn't work for you, then you may download "tar" source and compile it. 

Use 'XZ' utils to un-compress .xz files

$wget http://tukaani.org/xz/xz-5.0.5.tar.gz  $cd xz-5.0.5  $./configure  $make  $sudo make install

Once the package is installed, run the below command to uncompress .xz file formats.

xz -d filename.tar.xz

Common Linux Server Issues & Solution

Scenario:1 On one of my Production SuSE Linux (VMware Virtual Server ) , Storage team has extended partition (RDM disk ) from their end. Now how to rescan that partition and extend without rebooting from the Linux ?
Solution : In My case 8th disk on Controller-1 was extended by the Storage Team.So first rescan it. Using the below Command :
[root@binpipe ~]# echo 1 > /sys/class/scsi_device/device/rescan
In the above command replace the device info according to your setup.
[root@binpipe ~]# echo "1" > /sys/class/scsi_device/0\:0\:8\:0/device/rescan
Now resize the PV using the pvresize Command.
[root@binpipe ~]# pvresize /dev/dm-7
Check the size of Volume Group using vgs command and it should display the new extended size. Using lvextend command we can now easily extend or increase the size of lvm partition.
Scenario:2 On one of my Linux Server, Oracle database was not running because of tmpfs . Oracle Team wants to extend the tmfs file system size from 2 GB to 4GB.
Solution: tmpfs is a RAM based temporary file system which is generally mounted on /dev/shm. To to extend the tmfs file system use below steps :
Step:1 Check tmfs file system size.
[root@binpipe ~]# df -h /dev/shm/
Filesystem Size Used Avail Use% Mounted on
tmpfs      2.0G 148K 2.0G   1% /dev/shm
[root@binpipe ~]#
Step:2 Edit the /etc/fstab file.
Change the size as shown below :
tmpfs /dev/shm tmpfs size=4g 0 0
Step:3 remount the file system using mount command
[root@binpipe ~]# mount -o remount tmpfs
Step:4 Now check the tmfs file system
[root@binpipe ~]# df -h /dev/shm/
Filesystem Size Used Avail Use% Mounted on
tmpfs       4.0G 148K 4.0G  1% /dev/shm
[root@binpipe ~]#
Scenario:3 How to check which disks are used for Oracle ASM in Linux ?
Solution : To display the Oracle ASM disk, use below command :
root@binpipe:~# oracleasm listdisks
To Query a particular disk, use below command
root@binpipe:~# oracleasm querydisk -d /dev/sdq1
Scenario:4 In one of my Linux box , NAS share was mounted on the directory under /archive2015. Space of the NAS share was 150 GB and used size is 137 GB but when we try to create any file or directory we were getting “Disk Quota Exceed” error.
Solution: As it was NAS file system so from the OS perspective we can’t set quota on this. So in my case i contact to Storage team , ask them to check quota limit ( soft quota & Hard quota ). From the Storage Team we got the confirmation that quota limit is set ( Soft quota = 85 % & Hard Quota = 100 % ) and Grace period of 7 Days is also set.
So in our case soft quota limit was reached and no one has reduce the space utilization for 7 Days, so on 8th day Soft Quota limit becomes Hard Quota that’s why we are getting Disk Quota exceed error.
Scenario:5 For same file system df and du command shows different disk usage.
Solution: This could be because of open file deletion, i.e when someone delete a log file that is being used or open by other process if we try to delete this file then file name will be deleted buts it’s inode and data will not be deleted.
with the help “lsof” command we can determine the deleted files of /var that are still open :
$ lsof /var | egrep "^COMMAND|deleted"
So to release the space , we can kill the command with its PID using kill command.

PASSWORDLESS SSH LOGIN WITH 'SSHPASS' (WITHOUT SSH KEYS)

Compile and Install SSHPASS

1. Download the latest SSHPASS package from
http://sourceforge.net/projects/sshpass

2. Extract the package to a directory.

3. Run the following commands to compile SSHPASS:

# ./configure
# make
# make install
# make clean

4. Installation is complete.

Login to ssh server called server.example.com with password called t@uyM59bQ:
# sshpass -p 'p@ssword' ssh username@server.test.com

Under shell script you may need to disable host key checking:
# sshpass -p 'p@ssword' ssh -o StrictHostKeyChecking=no username@server.test.com

MYSQL 'Already has more than max_user_connections' & 'Cannot send session cache limiter' Issue & Solution

MYSQL 'Already has more than max_user_connections' & 'Cannot send session cache limiter' Issue & Solution is discussed below. Hope this helps.


ISSUE:
Warning: mysqli_real_connect(): (42000/1203): User sphn_vtig1 already has more than 'max_user_connections' active connections in /home/sphn/public_html/vt_vb/libraries/adodb/drivers/adodb-mysqli.inc.php on line 123

SOLUTION:

Solution could be any of the following:

1.  Use separate DB user to connect to vtiger and to connect the script that imports data every few minutes. This way each user will use its own connection limit.  Also, check that the connection is closed by the script after it inserts data. If not close it otherwise it will open too many connections till the timeout value is reached.


2. Try the following if you have root access to the server, or let me know. You can call me anytime if any help is needed.

The option max_user_connections is a limit imposed, not on the total number of simultaneous connections in the server instance, but on the individual user account.

Let's say the user is called db_user@localhost. You can find out what this user's connection limit is. Start by running this query:

SELECT max_user_connections FROM mysql.user
WHERE user='db_user' AND host='localhost';
If this is a nonzero value,change it back with

GRANT USAGE ON *.* TO db_user@localhost MAX_USER_CONNECTIONS 0;
or

UPDATE mysql.user SET max_user_connections = 0
WHERE user='db_user' AND host='localhost';
FLUSH PRIVILEGES;

This will cause mysqld to allow the user db_user@localhost to use the global setting max_user_connections as its limit.

Once you get to this point, now check the global setting using

SHOW VARIABLES LIKE 'max_user_connections';

If this is a nonzero value, you need to do two things

THING #1 : Look for the setting in /etc/my.cnf

[mysqld]
max_user_connections = <some number>
comment that line out

THING #2 : Set the value dynamically

SET GLOBAL max_user_connections = 0;

MySQL restart is not required.


ISSUE: 
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/sphn/public_html/vt_vb/libraries/adodb/drivers/adodb-mysqli.inc.php:123) in /home/sphn/public_html/vt_vb/libraries/HTTP_Session/Session.php on line 161

SOLUTION:

"Headers already sent" means that your PHP script already sent the HTTP headers, and as such it can't make modifications to them now.

Just make session_start the first thing you do in your PHP file. 
Put <?php session_start(); ?> above everything and it will work.

Creating Offline RPM Repository in Redhat & CentOS Linux

Redhat / CentOS flavours of Linux use YUM to manage software updates and package installers. Here are the steps to create a local offline repository for installation.

Creating RPM Repository in Local Server

1. Insert your Red hat DVD installer inside DVD ROM.
2. Mount the DVD by
[root@localhost ~]#mounts /dev/cdrom /media
3. Create a folder of your choice. In my case I have created /home/rpms
4. Copy all the RPM from /media/Server/ to /hom/rpms folder
[root@localhost ~]#mkdir /home/rpms  [root@localhost ~]#cp -rv /media/Server/*  /home/rpms
6. Now look for a folder /etc/yum.repos.d. If the directory exists then YUM package is already installed and you can skip this step. So you just need to configure. If it is not there you have to install yum and yum-utils package. Also install one RPM called createrepo.
[root@localhost rpms]# cd /media/Server/  
[root@localhost Server]# rpm -ivh yum-3.0.1-5.el5.noarch.rpm  
[root@localhost Server]# rpm –ivh yum-utils-1.0.4-3.el5.noarch.rpm  
[root@localhost Server]# rpm -ivh createrepo-0.4.4-2.fc6.noarch.rpm
7. Once YUM packages are installed you will get the /etc/yum.repos.d folder. Go inside the folder and open the entire .repo file present inside that folder. In all .repo file search for
enabled = 1
and replace by
enabled = 0
This means you are disabling the default repository locations or else you can delete all repo files.
8. Edit the /etc/yum.conf file,change the following line:

keepcache=0 to keepcache=1
9. Now prepare the directory /rpms to act as a repository. For this we run the command
[root@localhost ~]createrepo -p /rpms 
This command will take some time to finish and once finished you can see a directory called repodata will be created inside the /rpms directory.
11.If some error comes like "Cannot delete .olddata" Then you have to remove it manually by "rm -rf /home/rpms/.olddata"
yum error 39
10. Now create a file myrepo.repo inside /etc/yum.repos.d folder
[root@localhost ~]touch /etc/yum.repos.d/myrepo.repo
11. Put the following contents inside the myrepo.repo file
[myrepo]   name=My Local Repo   baseurl=file:///home/rpms   enabled=1   gpgcheck=0
Save the file and exit.
Now your repository is ready. Before running any installation first clean the cache by
Yum clean all
Now you can install anything like
[root@localhost ~]yum install httpd
You will get a screen like below where you have to say "y" or "n"
yum installation
N:B-Here I have used file:// protocol as base url.You can use ftp:/// or http:// if you have remote repository location.

Common Errors and their solutions

1)Errno 256:Metadata file does not match checksum
Solution:
1) Edit /etc/yum.conf and add the following line
http_caching=packages
2) Run "yum clean metadata"
3) Retry the yum install
2)"TypeError: rpmdb open failed" or "TypeError: rpmdb unable to join the environment"
Solution:
# yum clean all  
#rm -f /var/lib/rpm/__db*  
#rpm –rebuilddb  
#yum update
3)ValueError: need more than 1 value to unpack
Solution:
#yum clean all

#yum clean metadata
#yum clean dbcache

and then execute
#yum makecache
4)thread.error: can't start new thread
Solution:
#rm /usr/lib/yum-plugins/ threading.py
#yum update
5)[Errno -3] Error performing checksum
Solution:
#createrepo -v -s sha1 <repository location>
#yum clean all
6)TypeError: unsubscriptable object
Solution:
#yum clean metadata
#yum update missing dependency error
Solution:
#yum clean all
#yum update
7)Yum install GPG error
Solution:
#rpm --import /etc/pki/rpm-gpg/RPM*
8)Error: Cannot retrieve repository metadata (repomd.xml)
Solution:
This is a network issue.Please check DNS,Proxy etc. settings for the same.

ORACLE DATABASE DUMP USING EXPORT

To take the full database export (Oracle 10g):

Create a Export Directory:
##########################

On Solaris:
-----------
SQL> create or replace directory sys_dmp as '/u02/expdp';
Directory created.

On Windows:
-----------
SQL> create or replace directory sys_dmp as 'D:\expdp';
Directory created.

Create a separate export user:
##############################

SQL> Connect /as sysdba

SQL> CREATE USER expdpadmin IDENTIFIED BY expdp default tablespace users;
User created.

Grant Export and Import Privileges.
###################################

SQL> GRANT CONNECT,RESOURCE TO expdpadmin;
Grant succeeded.

SQL> GRANT exp_full_database to expdpadmin;
Grant succeeded.

SQL> alter user expdpadmin quota unlimited on USERS;
User altered.

SQL> GRANT READ, WRITE ON DIRECTORY SYS_DMP to expdpadmin;
Grant succeeded.

To check on which directories you have privilege to read & write:
#################################################################

SQL> SELECT privilege, directory_name
2 FROM user_tab_privs t, all_directories d
3 WHERE t.table_name(+)=d.directory_name
4 ORDER BY 2,1;

Exporting Full Database:
########################

expdp expdpadmin/XXXXXX full=y directory=sys_dmp dumpfile=full_db_expdp.dmp logfile=full_db_expdp.log
Simple Steps: how to perform a full database export using export utility.

* Use either system user or any other database user who has the EXP_FULL_DATABASE privilege.
* Set the NLS_LANG environment variable according the database character set and language details.
SQL> select * from nls_database_parameters
2 where parameter in ('NLS_LANGUAGE','NLS_TERRITORY','NLS_CHARACTERSET');

PARAMETER VALUE
------------------------------ ----------------------------
NLS_LANGUAGE AMERICAN
NLS_TERRITORY AMERICA
NLS_CHARACTERSET WE8ISO8859P1

Windows (Dos Prompt):
C:\> set NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

Unix/Linux:
$ export NLS_LANG=AMERICAN_AMERICA.WE8ISO8859P1

* Start the export with following command and options.

exp system/password@mydbfile=c:\exportdmp\exp_fulldb_MYDB_27Aug08.dmp
full=y log= c:\exportdmp\exp_fulldb_MYDB_27Aug08.log

Note: This is just a simple export command to perform the full database export. I would request and suggest you to refer Oracle Documentations on export/import and their options. Check the references.

Help on Export and Import:

Windows:
C:\> exp help=y
C:\> imp help=y

Linux/Unix.
$ exp help=y
$ imp help=y

References:

Oracle 10g :
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/exp_imp.htm

Oracle 9i:
http://download.oracle.com/docs/cd/B10501_01/server.920/a96652/part1.htm#435787

Oracle 8i:
http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76955/ch01.htm
http://download-west.oracle.com/docs/cd/A87860_01/doc/server.817/a76955/ch02.htm
SHELL SCRIPT FOR DB EXPORT
#!/bin/bash
ORACLE_BASE="/user/oracle"
PATH="$PATH:$ORACLE_HOME/bin:$JAVA_HOME/bin"
ORACLE_HOME=$ORACLE_BASE/OraHome
ORACLE_SID=PLMDPRD
PATH="$PATH:$ORACLE_HOME/bin:$JAVA_HOME/bin"
export PATH
export LD_LIBRARY_PATH="$ORACLE_HOME/lib"
export ORACLE_SID=PLMDPRD
dt=`/bin/date +%d%m%y%H%M%S`
exportfile="/user/oracle/PLMDPRD/PLMDPRD_${dt}".dmp
#exp / full=Y file=$exportfile  buffer=512000 compress=N   statistics=none
exp user/password@PLMDPRD   buffer=512000 compress=N  file=$exportfile statistics=none GRANTS=Y  full=Y
exit 0

CLONE ORACLE DATABASE FOR PLM

1. Stop the Oracle Database in source server


~oracle-user$ sqlplus '/as sysdba'

SQL> shutdown abort;
ORACLE instance shut down.

~oracle-user$ lsnrctl stop


2. Copy or Rsync the /user/oracle directory to destination server
Also copy the /misc directory if log files are archived there


3. Once done enter the Destination server as oracle user then run the
following:


~oracle-user$ sqlplus '/as sysdba'


SQL> startup mount;
ORACLE instance started.

Total System Global Area 1610612736 bytes
Fixed Size 2084296 bytes
Variable Size 385876536 bytes
Database Buffers 1207959552 bytes
Redo Buffers 14692352 bytes
Database mounted.



MEMBER
--------------------------------------------------------------------------------
/misc/oradata/PLMDPRD/redo/redo01.log

SQL> recover database until cancel using backup controlfile;
ORA-00279: change 265595845 generated at 02/01/2015 11:58:23 needed for thread1
ORA-00289: suggestion : /misc/oradata/PLMDPRD/arch/1_8626_731024280.dbf
ORA-00280: change 265595845 for thread 1 is in sequence #8626

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
/misc/oradata/PLMDPRD/redo/redo01.log
Log applied.
Media recovery complete.


SQL> shutdown abort;

SQL> startup;
ORACLE instance started.

Total System Global Area 1610612736 bytes
Fixed Size 2084296 bytes
Variable Size 385876536 bytes
Database Buffers 1207959552 bytes
Redo Buffers 14692352 bytes
Database mounted.
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open


SQL> alter database open resetlogs;

Database altered.

SQL> shutdown abort;

SQL> startup;
ORACLE instance started.

Total System Global Area 1610612736 bytes
Fixed Size 2084296 bytes
Variable Size 385876536 bytes
Database Buffers 1207959552 bytes
Redo Buffers 14692352 bytes
Database mounted.
Database opened.



SQL>quit

Now startup oracle listner and use the database.

Installing RPM's from a list

We will try to install RPM packages from a file containing a list. The following command generates a list of installed RPM packages:

rpm -qa

The same command but output the list into a file:

rpm -qa > rpms.txt

Now we can install the list of RPM packages based on the contents of the file “rpm.list”:

yum install `cat rpms.txt | sed 's/-[0-9]/*/' | cut -d"*" -f1`

The above command will use “yum” to install all packages as listed in the “rpms.txt” file.

The password hash in /etc/shadow file in Linux

The /etc/shadow file stores user passwords as hashes in a particular
format. If you ever want to verify users passwords against this hash
in a non standard way, like from a web app for example, then you need
to understand how it works.

Each row in /etc/shadow is a string with 9 fields separated by ':'. A
typical line looks like this:

binpipe:$6$vb1tLY1qiY$M.1ZCqKtJdfdfdQQCkaJT6wXqjUkFcA/qNxLygg,Lj/:15405:0:99999:7:::

The hash could be some random string like
43137ce13e6fdedf9a23792ae62a0aeda1e075409427d57332

The nine different fields are:

The local username
The password hash, more on this later
Number of days since the start of unix time (01/01/1970) that the
password was last changed
Minimum number of days before the password can be changed
Maximum number of days before the password must be changed. 99999
means that the user will not be forced to change their password
Number of days before forcing the password change that the user
will be warned.
The number of days after expiration that the account will be disabled
Days since the start of unix time that the account has been disabled
Currently unused but reserved for future use

Most of those fields are generally unused by Linux distros. The
important ones are the username and hash. The hash field itself is
comprised of three different fields. They are separated by '$' and
represent:

Some characters which represents the cryptographic hashing
mechanism used to generate the actual hash
A randomly generated salt to safeguard against rainbow table attacks
The hash which results from joining the users password with the
stored salt and running it through the hashing mechanism specified in
the first field

Make sense?

So that first field before the salt and actual hash can have a finite
set of possible values. The standard methods supported by GNU/Linux
are:

Available algorithms:

$1$
md5
$2a$
Blowfish
$2y$
Blowfish, with correct handling of 8 bit characters
$5$
sha256
$6$
sha512

In practice you shouldn't use anything but sha512. The mkpasswd
command will create the hash string for you and can be used by other
programs to check an existing hash. Given the password hash above, if
you wanted to check if a given password matched it you would run the
following command:

mkpasswd --method=sha512 --salt=vb1tLY1qiY PASSWORD

The equivalent using python looks like this:

import crypt

crypt.crypt('PASSWORD', '$6$vb1tLY1qiY')

Both will return an exact copy of the hash. for the given salt and
password. Notice how using the Python library you actually pass in the
method as part of the salt string. A salt string starting with '$5$'
would use sha256 for example.

You can then compare this hash with the hash in /etc/shadow, or
anywhere else that they might be stored. Like in a central datbase if
you are using NSS.

If you don't provide mkpasswd with a salt it will automatically
generate a random salt. This is usually what you want to do if you are
creating a password for the first time.

Notes on Legato Networker Recovery - 2

Recovering files that have dropped out of the browse period.


Why ? Legato Networker has a concept of browse policy and retention policy. When you do backups with Networker, a client index is created, which allows easy file recovery at a future date. However, many sites want to keep tapes for a long time before re-using them. This varies from three months to two years from site to site. However, the size of the browsable index would become huge on a large system. Whilst it may well be possible to keep a years worth of on-line index for a small system, for a large sites' main UNIX fileserver it would be ridiculous, as maybe fifty gigabytes of disk area would be required just to store the index. So, the retention period is how long the tapes are kept after the last saveset was written to the tape, and the browse policy is how long the entries for recovering are kept in the Legato server's on-line index.

The usual policy is to have a browse policy of a month. This satisfies the large majority of file restore requests that are received, and gives an index overhead of about 2% or so.

If someone then comes in and wants a file recovered that was deleted two months ago, the recovery operation is more complicated than recovering a file deleted two weeks ago.

There are two approaches to recovering these files that are not in the file index any more.

    Recovering the browsable index
    Recovering without an index

Also, scanner with no options gives no feedback unless it is recovering. On slow tape devices like DATs, this can mean hours without any indication of things in progress. To get more information on what's happening, see getting feedback on scanner progress
Recovering the browsable index.
One is to rebuild the online index using the scanner command on the Legato server.

First of all, you need to know when the file was created, and when it was last in a satisfactory state. Given this information, you can then find out what tape it's on using the  mminfo command.  It's normally easier to get the file from a full backup, especially if  the owner is unsure of it's creation date.
The easiest way to get the index back is with

scanner -i -S SaveSetID  /dev/rmt/non-rewind

However, the entries added into the index will never be automatically purged,  you must pull them out by hand with nsrmm -d -P  -S SaveSetID  You MUST put in the -P option, otherwise you delete the entries from the media index as well as the browsable file index. This is disastrous, as it means you cannot repeat the exercise without running scanner -m on the deleted volumes. This isn't a problem if you realise straight away. However, when all you know is that one of the 200 tapes was purged from the media index, you have a lot of work ahead of you.

As an example, here is an entry for a scanned-in saveset.

wlfiles# mminfo -v -q 'ssid=46095'
 volume        client       date     time      size       ssid fl  lvl name
wl.incr.031.DLT wlntsv1   04/22/98 21:20:28  283 MB      46095 cS incr E:\
wlfiles#

The cS filed at the right in the fl field means the complete saveset is on this tape, and it is manually scanned in.
Once the recover is complete, we want to remove the index entry.
So, given the info above,

wlfiles# nsrmm -d -P  -S 46095
Purge file index entries for save set `46095'? y
wlfiles#

This deletes the entry from the  file index, but leaves the media index entries alone. So, when we run  a query again, we get:

wlfiles# mminfo -v -q 'ssid=46095'
 volume        client       date     time      size       ssid fl  lvl name
wl.incr.031.DLT wlntsv1   04/22/98 21:20:28  283 MB      46095 cr incr E:\
wlfiles#

The S in the fl field has now changed to an r. Where S stands for Scanned-in, r means recoverable, or can be got back from the tape.
The other options in the second character are b for browsable, i.e. still in the file index, and E, for eligible for recycling.

If you have different SSID numbers that follow on as they are part of the same filesystem, just delete the first in the series

dfe@nsrhost> mminfo -v -q volume=wl.full.091.DLT,volume=wl.full.092.DLT | grep 'E:'

wl.full.091.DLT wlntsv1   04/02/99 01:08:00 2000 MB     172818 cS full E:\
wl.full.091.DLT wlntsv1   04/02/99 01:08:01 2000 MB     172820 cS full <1>E:\
wl.full.091.DLT wlntsv1   04/02/99 01:08:02  893 MB     172824 hS full <2>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:02 1107 MB     172824 tS full <2>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:03 2000 MB     172825 cS full <3>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:04 2000 MB     172828 cS full <4>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:05  250 MB     172829 cS full <5>E:\

dfe@nsrhost> nsrmm -d -P -S 172818
dfe@nsrhost> mminfo -v -q volume=wl.full.091.DLT,volume=wl.full.092.DLT | grep 'E:'

wl.full.091.DLT wlntsv1   04/02/99 01:08:00 2000 MB     172818 cr full E:\
wl.full.091.DLT wlntsv1   04/02/99 01:08:01 2000 MB     172820 cr full <1>E:\
wl.full.091.DLT wlntsv1   04/02/99 01:08:02  893 MB     172824 hr full <2>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:02 1107 MB     172824 tr full <2>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:03 2000 MB     172825 cr full <3>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:04 2000 MB     172828 cr full <4>E:\
wl.full.092.DLT wlntsv1   04/02/99 01:08:05  250 MB     172829 cr full <5>E:\
dfe@nsrhost>

Deleting the first part of the series deleted all the parts of the series.

    Back to the top

Recovering files without the browsable index.
You don't need the browsable index to do file recovers.

The easiest way is to use the nwadmin program, and to select the "Save Set" then "Recover" option from the menu. Select the client you wish to recover for, then select the save set you wish to recover, and select the date you wish to recover from. Next, click the recover button.  You MUST give a filter on the "Paths to recover" window in the Save Set Recover window, otherwise you will attempt to recover all the files in the save set, which will add least fill up your disks and could result in you over-writing later data with the data from the backup tapes.

This does rely on you knowing accurately  the date that the file was last modified, and the full pathname of the file. If you do not have this, you can relocate the data to a new disk area, and then the file owner can browse this filesystem to find the file they want.
 

It is also possible to use command-line tools to recover the files, but this is harder.

For example, I want to recover a file that I created at the end of August, deleted in the middle of September. I'm unsure of the exact dates. You work out that the file is in my home directory, under projects/plans/mail-upgrade.text  You can work out that my home directory is wlfiles:/local34.

Next, find out which tapes this will be on.

mminfo -q 'level=full, savetime >= 09/01/97, client=wlfiles, name=/local34' -v

 volume        client       date     time      size       ssid fl  lvl name
wl.full.024.DLT wlfiles   09/06/97 01:17:57 2000 MB      87800 cr full /local34
wl.full.029.DLT wlfiles   09/20/97 01:28:17  595 MB      90659 hr full /local34
wl.full.030.DLT wlfiles   09/20/97 01:28:17 1405 MB      90659 tr full /local34
wl.full.034.DLT wlfiles   10/04/97 01:22:25  842 MB      93611 hr full /local34
wl.full.035.DLT wlfiles   10/04/97 01:22:25 1158 MB      93611 tr full /local34
wl.full.041.DLT wlfiles   10/18/97 03:49:44 2000 MB      96735 cr full /local34
wl.full.044.DLT wlfiles   10/24/97 01:31:49 2000 MB      98263 cb full /local34
wl.full.047.DLT wlfiles   11/06/97 22:00:31 2000 MB     101439 cb full /local34
wl.full.051.DLT wlfiles   11/20/97 22:01:46 2000 MB     104043 cb full /local34

the tapes that are cr or cb are the easiest to work from, as only one tape is needed. ( it's c for complete, i.e. stored on one tape. ) This means that the backup dated  09/06/97 on tape wl.full.024.DLT is the one we want.  Unfortunately, you cannot have a <= for savetime, so we get everything since October 1st 1997 until the present date..

Some disks have more data than Legato can fit into a single save set. In these cases,  the save set is split up into multiple save set IDs, but if each save set is on one tape, it will be marked as complete. The following parts of the save set have a different SSID number, and following the save name /savearea, the following saves have a save name of <1>/savearea, <2>/savearea, and so on.

Below is a save set listing for a 9 gig disk.

wl.full.021.DLT wlfiles   08/30/97 02:31:24 2000 MB      86393 cr full /local15
wl.full.021.DLT wlfiles   08/30/97 02:31:25 2000 MB      86396 cr full <1>/local15
wl.full.021.DLT wlfiles   08/30/97 02:31:26 2000 MB      86401 cr full <2>/local15
wl.full.021.DLT wlfiles   08/30/97 02:31:27  544 MB      86409 hr full <3>/local15
wl.full.022.DLT wlfiles   08/30/97 02:31:27  750 MB      86409 tr full <3>/local15
 

Back to the top  save set list. Next, to speed up the recover operation, we want very verbose reporting on ssid 87800

To get these, we run:

mminfo -q 'ssid=87800' -V

Which produces a lot of output. To make life easier, use

mminfo -q 'ssid=87800' -V -o t | head

which will return the details with the starting point at the top of the list, and the first entry will be the one of interest.

mminfo -q 'ssid=87800' -V -o t | head -4
 volume        client       date     time      size   level  name
  save time       ssid      first       last file  rec      volid      total fl
wl.full.024.DLT wlfiles   09/06/97 01:17:57  4.4 MB    full  /local34
  873505077      87800          0    4548907   97 5839        662 2048003016 hr

So, we place the tape  wl.full.024.DLT  into the tape device, mount the tape and run:

scanner -S 87800 -f 97 /dev/rmt/non-rewind-dev | uasm -rv /local34/users/itss/dfe/projects/plans/mail-upgrade.text

Some Legato servers do not prefix the directory info as part of the save set information. In these cases, the directory specified in the client setup save set options is treated as the root file system for the backup.

scanner -S 87800 -f 97 /dev/rmt/non-rewind-dev | uasm -rv /users/itss/dfe/projects/plans/mail-upgrade.text

The /users/itss/dfe/projects/plans/mail-upgrade.text entry  is a prefix, so if you had the entry as /users/itss/dfe/projects/plans You would recover all files below the plans subdirectory.

This will recover  the file mail-upgrade.text as long as it doesn't exist.

uasm -rv -iY will overwrite the existing file
uasm -rv -iR will rename the recover file from filename through filename.R  to filename.R.R and prompt for intervention if the file already ends in a .R ( default response is add another .R but this cannot be made automatic from the documented uasm options )

In the example above for the save sets plit up into 2 gig chunks, scanner will automatically roll forward onto the next save set, as long as it is on the same tape. When SSID 86409 for name <3>/local15  runs out, you will be prompted for the location of the next tape, and then for the optional file and record numbers. Use mminfo -V -q 'ssid=nnnn' again to work out the file number, Just press return for the record number.

If you do not know the path names, you can use

 scanner -S ssid /dev/rmt/0bn | uasm -rvn

This will perform a dry run, consuming the input stream and doing basic health checks on it, but not creating any of the files or directories in the scanner stream ( or the uasm -s stream )

If you wish to recover the files into a new location, you can use the -m/src=/dest option to uasm. This replaces the start of the save set files that begin with /src to start with /dest.

For example,

scanner -S 87800 -f 97 /dev/rmt/non-rewind-dev | uasm -rv /users/itss/dfe/projects/plans/mail-upgrade.text -m/users/itss=/var/tmp

would place all the files into /var/tmp/dfe with appropriate subdirectory structures.
Back to the top


Getting feedback on scanner progress.
The scanner commands work quietly, only producing output when they are actually working on the desired articles. To increase the detail of what is being down, use the -p option, which will print out information save set notes as they are processed, even if they are nothing to do with the current request. -v turns on more verbose reporting, with a tag every hundred records.

These messages are printed to the standard error output, so you can safely use them in a pipe. The -S returns go to standard output, so in the examples above end up being fed into uasm, the -pv returns go to your display without affecting the uasm input.

Courtesy: http://www-wl.itss.nerc.ac.uk

Notes on Legato Networker Restore Operation - 1

Performing Recoveries from Command Line

 

Networker recover command

 

The recover command runs in two modes:

 

  • Interactive mode � Interactive mode is the default mode for the recover command. This mode places you in a shell-like environment that allows you to use subcommands. These commands let you navigate the client file index to select and recover files and directories.

 

  • Non-interactive mode (-a option) � In non-interactive mode, the files specified on the command line are recovered automatically without browsing. To activate non-interactive mode, use the �a option.

 

Using recover in Interactive Mode:

 

Login to the server you need to recover the file for and then type recover.  This will place you in the recover shell environment.  You can also type recover  [pathname] to set your initial working directory (recover /etc), the default is the current working directory.

 

[root@legatounixmst /]$recover

recover: Current working directory is /

recover>

 

[root@legatounixmst /]$recover /etc

recover: Current working directory is /etc/

recover>

 

*Note: If you do not get a recover prompted when you type recover, add a �s servername option.

 

[root@legatounixmst /]$recover  -s legatounixmst.itd.bnl.gov

 

 

The following commands let you navigate and client file index to select and recover files and directories.

 

Option

Description

ls

Lists information about the given files and directories. When no name argument is provided, ls lists the contents of the current directory. When you specify a directory as name, the directory�s contents are displayed.

cd

Changes the current working directory to directory. The default is the directory in which you executed recover.

pwd

Prints the full pathname of the current working directory.

add [name.. ]

Adds the current directory or the named files or directories to the recover list. If a directory is specified, it is added with all of the subordinate files to the recover list.

delete [name..]

Deletes the current directory or the named files or directories from the recover list. If a directory is specified, that directory and all of the subordinate files are deleted from the recover list.

versions [name..]

List all available versions for a file or directory. If no name is given the current working directory is used.

changetime

Change the backup browse time to recover files before the last backup. You will be prompted for new time. Time can be entered as December 15, 2004 or 12/15/2004.

list

Displays the files on the recover list.

recover

Recovers all files on the recover list from the Networker server. Upon completion, the recover list is empty.

exit

Exits immediately from the recovery

quit

Exits immediately from the recover. Files on the recover list are not recovered.

 

 

 

Using recover in Non-interactive mode:

 

In non-interactive mode, the files specified on the command line are recovered automatically without browsing. To activate non-interactive mode, use the option.

 

Examples:

 

Recover the /etc/hosts file from the most recent backup

 

recover  > /etc/hosts

 

 

Using the recover Command in Directed Recoveries:

 

To relocate recovered files use the �d destination option with the recover command. 

 

Examples:

 

To direct recovered files to /restore directory in interactive mode

 

               recover  -d /restore

 

To direct the recovery of /etc/hosts file to /restore directory in non-interactive mode

 

               recover  -a -d /restore /etc/hosts

 

 

[root@legatounixmst /]$recover -a -d /restore /etc/hosts

 

Recovering 1 file from /etc/ into /restore

Requesting 1 file(s), this may take a while...

./hosts

Received 1 file(s) from NSR server `legatounixmst.itd.bnl.gov'

Recover completion time: Thu Nov 18 14:39:15 2004

 

Using the recover Command to recover a file from a specific date:

 

Enter the recover shell by typing recover.

Locate the file you need to restore using the ls and cd commands.

List the versions for the file using the versions command,

Use the changetime command to change to the day the file was backed up

Add the file to the recovery list using the add command.

 

 

[root@legatounixmst /]$recover

recover: Current working directory is /

recover> versions /etc

 

Versions of `/etc/':

 

   4 drwxr-xr-x root     sys          4096 Jan 13 17:48  etc/

     save time:  Thu Jan 13 18:10:27 2005       

      location:  ACW057S2 at PX720

 

   4 drwxr-xr-x root     sys          4096 Jan 12 17:48  etc/

     save time:  Wed Jan 12 18:07:05 2005       

      location:  ACW059S2 at PX720

 

   4 drwxr-xr-x root     sys          4096 Jan 11 17:48  etc/

     save time:  Tue Jan 11 18:09:28 2005       

      location:  ACW062S2 at PX720

 

   4 drwxr-xr-x root     sys          4096 Jan 10 19:48  etc/

     save time:  Mon Jan 10 20:18:09 2005       

      location:  ACW062S2 at PX720

 

recover> changetime 1/9/2005

time changed to Sun Jan  9 23:59:59 2005

recover> add /etc

recover> recover



Courtesy: http://quark.phy.bnl.gov