OpenVZ - Operation not permitted on changing date



Error:

When you try to set date in a OpenVZ container, it may show Operation not permitted error.


Reason:

The capability for setting time is not given for the container.
sys_time capability mustbe enabled for the container to set the date and time.


Solution:

1. Login to OpenVZ Hardware Node as root user.

2. [root@HN ~] # vzlist -a | grep <IP of VPS>
                  <VPSID>         59  running   <IP>  server.example.com

3. [root@HN ~] # vzctl stop <VPSID>

4. [root@HN ~] # vzctl set <VPSID> --capability sys_time:on --save

5. [root@HN ~] # vzctl start <VPSID>


Now the capability parameter for changing time is given for the container.
Try again changing the date. This time it will permit you to change the date and time.

Reference:
http://wiki.openvz.org/Man/vzctl.8#Capability_option

Setup Full Server Remote Backup using rsync via SSH


Full Server Remote Backup using rsync via SSH



Step1:

Login to your server via ssh which you want to take backup. Login as root user.

Check the rsync operation in your server. This time it will ask for the password.

root@server [~] # rsync -avz -e ssh /test root@<BackupServerIP>:/backup/

You have to follow Step2 to make key based ssh login from a particular IP.


Step2:

In order to run the cronjob for creating backup, you need to configure rsync over ssh that doesn’t ask for a password.

Create an RSA encryption key for use with the SSH transport.

root@server [~] # ssh-keygen -t rsa -N ''

Use ssh-copy-id, to copy the public key to the remote host(Backup server).

root@server [~] # ssh-copy-id -i ~/.ssh/id_rsa.pub root@<BackupServerIP>

This time it will ask for the ssh password for the root user to copy the key.


Step3:

Test rsync over ssh without password

root@server [~] # ssh <BackupServerIP>

Now, you should be able to ssh to remote host without entering the password. If it is working fine perform a test rsync operation. It will not ask for password this time.

root@server [~] # rsync -avz -e ssh /test root@<BackupServerIP>:/backup/


Step4:

If Step3 passed the tests with rsync, you have to make a cronjob to run the backup periodically.

root@server [~] # crontab -e
0 1 * * * rsync -avz --exclude=/proc --exclude=/sys --exclude=/dev -e ssh / root@<BackupServerIP>:/backup



The above cronjob will take backup of the entire server excluding /proc, /sys and /dev direcories. The above cronjob will run on every day at 1AM.

Reference:
http://www.tutorialspoint.com/unix_commands/rsync.htm
http://www.thegeekstuff.com/2011/07/rsync-over-ssh-without-password/

Most Frequently used Commands in Exim


Most Frequently used Commands in Exim


Managing the Mail queue using 'exim' command



# exim -bpc
  -Print the total number of mail in mail queue.

# exim -bp
  -Print a listing of mails in the queue (time queued, size, message-id, sender, recipient)

# exim -bp | exiqsumm
  -Print a summary of messages in the queue (count, volume, oldest, newest, domain, and totals)

# exiwhat
  -To print what Exim is doing right now
----------------------------------------------------------------------------------------------------------------------------------


# exim -Mvh <message-id>
  -To view a message's headers

# exim -Mvb <message-id>
  -To view a message's body

# exim -Mvl <message-id>
  -To view a message's logs

# exim -Mes <message-id> <address>
  -To edit the sender of a message

# exim -Mrm <message-id>
  -To remove a message from the queue

# exim -Mf <message-id>
  -To freeze a message

----------------------------------------------------------------------------------------------------------------------------------

# exim -bp | awk '$6~"frozen" { print $3 }' | xargs exim -Mrm
or
# exim -bp | grep frozen | awk '{ print $3 }' | xargs exim -Mrm

  -To remove all frozen mails in the queue

----------------------------------------------------------------------------------------------------------------------------------

To check how exim will route a given address:



# exim -bt alias@localdomain.com
  user@thishost.com
    <-- alias@localdomain.com
  router = localuser, transport = local_delivery

# exim -bt user@localdomain.com
  user@localdomain.com
  router = localuser, transport = local_delivery

# exim -bt user@remotehost.com
  router = lookuphost, transport = remote_smtp
  host mail.remotehost.com [1.2.3.4] MX=0

=================================================================================

Managing the Mail queue using 'exiqgrep' command



Exim includes a utility called exiqgrep, that is very useful for grepping through the queue.

# exiqgrep -f user@domain.com
  -To search the queue for messages from a specific sender

# exiqgrep -r user@domain.com
  -To search the queue for messages for a specific recipient/domain

# exiqgrep -o <sec>
  -To print messages older than the specified number of seconds.

# exiqgrep -y <sec>
  -To print messages that are younger than the specified number of seconds.

# exiqgrep -i
  -To print the message-id of the entire queue

# exiqgrep -c
  -To print a count of messages


----------------------------------------------------------------------------------------------------------------------------------

# exiqgrep -zi | xargs exim -Mrm
# exim -bpr | grep frozen | awk {'print $3'} | xargs exim -Mrm
  -To remove all frozen messages

# exiqgrep -o 86400 -i | xargs exim -Mrm
  -To remove all messages older than 1 day.

# exiqgrep -i -f user@domain.com | xargs exim -Mf
  -To freeze all queued mail from a given sender

# exiqgrep -i -f '<>'  | xargs exim -Mrm
  -To remove all mail delivery failure mails.



Reference:-
http://bradthemad.org/tech/notes/exim_cheatsheet.php