<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://www.zarafa.com/wiki/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.zarafa.com/wiki/index.php?title=List_or_Remove_MSR_state_files_per_user&amp;feed=atom&amp;action=history</id>
		<title>List or Remove MSR state files per user - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://www.zarafa.com/wiki/index.php?title=List_or_Remove_MSR_state_files_per_user&amp;feed=atom&amp;action=history"/>
		<link rel="alternate" type="text/html" href="http://www.zarafa.com/wiki/index.php?title=List_or_Remove_MSR_state_files_per_user&amp;action=history"/>
		<updated>2013-05-24T17:28:25Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.16.0</generator>

	<entry>
		<id>http://www.zarafa.com/wiki/index.php?title=List_or_Remove_MSR_state_files_per_user&amp;diff=1944&amp;oldid=prev</id>
		<title>Msartor: Created page with &quot;In the situation when an MSR migration of a certain user goes wrong, you may want to restart the migration of only that user. In this case you'll probably only want to delete the...&quot;</title>
		<link rel="alternate" type="text/html" href="http://www.zarafa.com/wiki/index.php?title=List_or_Remove_MSR_state_files_per_user&amp;diff=1944&amp;oldid=prev"/>
				<updated>2012-03-13T11:12:43Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;In the situation when an MSR migration of a certain user goes wrong, you may want to restart the migration of only that user. In this case you&amp;#39;ll probably only want to delete the...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;In the situation when an MSR migration of a certain user goes wrong, you may want to restart the migration of only that user. In this case you'll probably only want to delete the MSR state files of that user.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The MSR state files are stored in the folder  ''.zarafa-migrate-store''  in the home directory of the user under which the MSR has been run. Inside this folder will be one or more subfolders, e.g.:&lt;br /&gt;
* f8d5f77df7be48fdbeba2f69e9f927a6-1fe3974ccbdf4e74be5874341cdd43b3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
These hex values are the GUIDS of the source and destination server, in the above example:&lt;br /&gt;
* Source GUID: f8d5f77df7be48fdbeba2f69e9f927a6&lt;br /&gt;
* Destination GUID: 1fe3974ccbdf4e74be5874341cdd43b3&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script below is able to list or remove state files of a certain user. You will need to change some variables at the top of the script to match your situation:&lt;br /&gt;
* MySQL credentials&lt;br /&gt;
* STATE_DIR:  You'll need to add the first subdirectory of  ''.zarafa-migrate-store''   in the STATE_DIR variable.  At the moment the script is not able to determine which server has which GUID. This still has to be done. So if you have more than 1 subdirectory inside  ''.zarafa-migrate-store''  you will need to find out for yourself which subdirectory you'll need.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Usage of the script:   msr_state.sh [option] [user_name]&lt;br /&gt;
&lt;br /&gt;
Options:&lt;br /&gt;
* -l [user_name]:   List state files of user [user_name]&lt;br /&gt;
* -r [user_name]:  Remove state files of user [user_name]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The script msr_state.sh:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
MYSQL_HOST=&amp;quot;localhost&amp;quot;&lt;br /&gt;
MYSQL_USER=&amp;quot;mysqluser&amp;quot;&lt;br /&gt;
MYSQL_PASS=&amp;quot;password&amp;quot;&lt;br /&gt;
MYSQL_DB=&amp;quot;zarafa&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# Set state dir, include source-dest entry id's&lt;br /&gt;
STATE_DIR=&amp;quot;/path/to/.zarafa-migrate-store/f8d5f77df7be48fdbeba2f69e9f927a6-1fe3974ccbdf4e74be5874341cdd43b3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
SRV_SRC_GUID=`echo ${STATE_DIR} | awk -F / {'print $NF'} | awk -F - {'print $1'}`&lt;br /&gt;
SRV_DEST_GUID=`echo ${STATE_DIR} | awk -F / {'print $NF'} | awk -F - {'print $2'}`&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;${SRV_SRC_GUID}&amp;quot; == &amp;quot;&amp;quot; ]; then&lt;br /&gt;
  echo&lt;br /&gt;
  echo &amp;quot;Source Server GUID is empty, expected a GUID, please check STATE_DIR.&amp;quot;&lt;br /&gt;
  echo&lt;br /&gt;
  exit 1&lt;br /&gt;
else&lt;br /&gt;
  echo&lt;br /&gt;
  echo &amp;quot;:: Using Source Server GUID: ${SRV_SRC_GUID}&amp;quot;&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if [ ! -e ${STATE_DIR} ]; then&lt;br /&gt;
  echo&lt;br /&gt;
  echo &amp;quot;State directory not found, please check configuration.&amp;quot;&lt;br /&gt;
  echo&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
USER_NAME=&amp;quot;$1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
case $1 in&lt;br /&gt;
  &amp;quot;-l&amp;quot;)&lt;br /&gt;
        ACTION=&amp;quot;ls&amp;quot;&lt;br /&gt;
	DESC=&amp;quot;Listing&amp;quot;&lt;br /&gt;
	USER_NAME=&amp;quot;$2&amp;quot;&lt;br /&gt;
        ;;&lt;br /&gt;
  &amp;quot;-r&amp;quot;)&lt;br /&gt;
        ACTION=&amp;quot;rm&amp;quot;&lt;br /&gt;
	DESC=&amp;quot;Removing&amp;quot;&lt;br /&gt;
	USER_NAME=&amp;quot;$2&amp;quot;&lt;br /&gt;
        ;;&lt;br /&gt;
esac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;${USER_NAME}&amp;quot; == &amp;quot;&amp;quot; ]; then&lt;br /&gt;
  echo&lt;br /&gt;
  echo &amp;quot;  Usage:  $0 [option] [user_name]&amp;quot;&lt;br /&gt;
  echo&lt;br /&gt;
  echo &amp;quot;  Options:&amp;quot;&lt;br /&gt;
  echo &amp;quot;    -l: List state files of user [user_name]&amp;quot;&lt;br /&gt;
  echo &amp;quot;    -r: Remove state files of user [user_name]&amp;quot;&lt;br /&gt;
  echo&lt;br /&gt;
  exit&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
USER_GUID=`mysql -h ${MYSQL_HOST} -u ${MYSQL_USER} -p${MYSQL_PASS} ${MYSQL_DB} -e &amp;quot;select hex(guid) from stores where user_name='${USER_NAME}'\G&amp;quot; | grep guid | awk {'print $2'}`&lt;br /&gt;
&lt;br /&gt;
GUIDS_FOUND=`echo ${USER_GUID} | wc -w`&lt;br /&gt;
&lt;br /&gt;
if [ ${GUIDS_FOUND} -ne 1 ]; then&lt;br /&gt;
  echo &amp;quot;&amp;quot;&lt;br /&gt;
  echo &amp;quot;Unable to resolve GUID of user ${USER_NAME}:&amp;quot;&lt;br /&gt;
  echo &amp;quot;&amp;quot;&lt;br /&gt;
  echo &amp;quot;     ${GUIDS_FOUND} GUIDS returned, only 1 was expected.&amp;quot;&lt;br /&gt;
  echo &amp;quot;&amp;quot;&lt;br /&gt;
  exit 1&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
LCASE_USER_GUID=`echo ${USER_GUID} | tr '[A-Z]' '[a-z]'`&lt;br /&gt;
&lt;br /&gt;
STATE_FILE_COUNT=`ls &amp;quot;${STATE_DIR}/${SRV_SRC_GUID}00000000${LCASE_USER_GUID}&amp;quot;* 2&amp;gt;/dev/null | wc -l`&lt;br /&gt;
echo &amp;quot;:: Found ${STATE_FILE_COUNT} STATE Files for user ${USER_NAME}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
if [ ${STATE_FILE_COUNT} -ne 0 ]; then&lt;br /&gt;
  echo &amp;quot;:: $DESC STATE Files for user ${USER_NAME}:&amp;quot;&lt;br /&gt;
  echo &amp;quot;::&amp;quot;&lt;br /&gt;
  ${ACTION} &amp;quot;${STATE_DIR}/${SRV_SRC_GUID}00000000${LCASE_USER_GUID}&amp;quot;*&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Msartor</name></author>	</entry>

	</feed>