<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>bash archivos - Nobody comes after the last</title>
	<atom:link href="https://blog.krusher.net/en/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Because someone had to think of the fishes</description>
	<lastBuildDate>Tue, 06 May 2025 14:57:19 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://blog.krusher.net/wp-content/uploads/2016/02/cropped-detras-del-ultimo-no-va-nadie-icon-32x32.jpg</url>
	<title>bash archivos - Nobody comes after the last</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>About how to clone a Prestashop instance</title>
		<link>https://blog.krusher.net/en/2025/05/about-how-to-clone-a-prestashop-instance/</link>
					<comments>https://blog.krusher.net/en/2025/05/about-how-to-clone-a-prestashop-instance/#respond</comments>
		
		<dc:creator><![CDATA[Krusher]]></dc:creator>
		<pubDate>Tue, 06 May 2025 14:57:19 +0000</pubDate>
				<category><![CDATA[Computing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[clone]]></category>
		<category><![CDATA[prestashop]]></category>
		<guid isPermaLink="false">https://blog.krusher.net/?p=2814</guid>

					<description><![CDATA[<p>Lately, I&#8217;ve been helping my neighbor with his Prestashop website. I&#8217;ve learned a few tricks, like editing the overall appearance of the site, making and restoring backups in a limited environment, but my best invention has been cloning the Prestashop instance to have a test version where I can try things out without fear of &#8230; <a href="https://blog.krusher.net/en/2025/05/about-how-to-clone-a-prestashop-instance/" class="more-link">Continue reading<span class="screen-reader-text"> "About how to clone a Prestashop instance"</span></a></p>
<p>La entrada <a href="https://blog.krusher.net/en/2025/05/about-how-to-clone-a-prestashop-instance/">About how to clone a Prestashop instance</a> se publicó primero en <a href="https://blog.krusher.net/en">Nobody comes after the last</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Lately, I&#8217;ve been helping my neighbor with his Prestashop website. I&#8217;ve learned a few tricks, like editing the overall appearance of the site, making and restoring backups in a limited environment, but my best invention has been cloning the Prestashop instance to have a test version where I can try things out without fear of breaking anything. Here&#8217;s the code for anyone who might find it useful, <a href="https://www.gnu.org/licenses/gpl-3.0.html#license-text" target="_blank" rel="noopener">licensed under GPL 3</a>.</p>
<p>You can see the code here, too: <a href="https://gist.github.com/axelei/dafd305213ed1b2655545f06edfbc905" target="_blank" rel="noopener">https://gist.github.com/axelei/dafd305213ed1b2655545f06edfbc905</a></p>
<pre class="brush: bash; title: ; notranslate">
# Programa para clonar prestashop
# Copyright Krusher 2015 - Licenciado bajo GPL3

paramfile=&quot;httpdocs/app/config/parameters.php&quot;
extractDatabaseName=&quot;s/.*&#039;database_name&#039; =&amp;gt; &#039;\(.*\)&#039;.*/\1/p&quot;
extractDatabaseUser=&quot;s/.*&#039;database_user&#039; =&amp;gt; &#039;\(.*\)&#039;.*/\1/p&quot;
extractDatabasePassword=&quot;s/.*&#039;database_password&#039; =&amp;gt; &#039;\(.*\)&#039;.*/\1/p&quot;

if &#x5B; &quot;$#&quot; -lt 4 ]; then
  echo &quot;Error: Se requieren 3 argumentos.&quot;
  echo &quot;Uso: $0 dir_web_original dir_web_destino url_original url_destino&quot;
  exit 1
fi

echo Traspasando de $1 a $2 \(urls: $3 -- $4 \)

databaseName=$(sed -n &quot;$extractDatabaseName&quot; $1/app/config/parameters.php)
databaseUser=$(sed -n &quot;$extractDatabaseUser&quot; $1/app/config/parameters.php)
databasePassword=$(sed -n &quot;$extractDatabasePassword&quot; $1/app/config/parameters.php)

echo Datos de la base de datos de origen: $databaseName / $databaseUser / $databasePassword

targetName=$(sed -n &quot;$extractDatabaseName&quot; $2/app/config/parameters.php)
targetUser=$(sed -n &quot;$extractDatabaseUser&quot; $2/app/config/parameters.php)
targetPassword=$(sed -n &quot;$extractDatabasePassword&quot; $2/app/config/parameters.php)

echo Datos de la base de datos de destino: $targetName / $targetUser / $targetPassword

if &#x5B;&#x5B; -z &quot;$databaseName&quot; ]] || &#x5B;&#x5B; -z &quot;$databaseUser&quot; ]] || &#x5B;&#x5B; -z &quot;$databasePassword&quot; ]] || &#x5B;&#x5B; -z &quot;$targetName&quot; ]] || &#x5B;&#x5B; -z &quot;$targetUser&quot; ]] || &#x5B;&#x5B; -z &quot;$targetPassword&quot; ]]; then
  echo &quot;Error: Algunas de las variables no han sido extraídas, comprueba los errores y los directorios.&quot;
  exit 1
fi

echo URL de la instancia origen: $3
echo URL de la instancia destino: $4

read -p &quot;Pulsa enter para continuar o CTRL+C para cancelar&quot;
echo  &quot;Procediendo con el traspaso.&quot;

echo Extrayendo base de datos
rm -f temp.sql
mysqldump -u $databaseUser $databaseName -p$databasePassword &amp;gt; temp.sql
echo Borrando base de datos objetivo
mysql -u $targetUser $targetName -p$targetPassword -e &quot;drop database $targetName; create database $targetName&quot;
echo Insertando la base de datos origen en la objetivo
mysql -u $targetUser -D $targetName -p$targetPassword &amp;lt; temp.sql
rm -f temp.sql

echo borra ficheros contenido antiguo
rm -Rf $2/*
echo copia ficheros
cp -r $1/* $2/

echo Configurando base de datos objetivo con los datos originales

sed -i &quot;s/&#039;database_name&#039; =&amp;gt; &#039;\(.*\)&#039;/&#039;database_name&#039; =&amp;gt; &#039;$targetName&#039;/g&quot; $2/app/config/parameters.php
sed -i &quot;s/&#039;database_user&#039; =&amp;gt; &#039;\(.*\)&#039;/&#039;database_user&#039; =&amp;gt; &#039;$targetUser&#039;/g&quot; $2/app/config/parameters.php
sed -i &quot;s/&#039;database_password&#039; =&amp;gt; &#039;\(.*\)&#039;/&#039;database_password&#039; =&amp;gt; &#039;$targetPassword&#039;/g&quot; $2/app/config/parameters.php

echo Configurando la nueva URL en la instancia destino

mysql -u $targetUser $targetName -p$targetPassword -e &quot;update prstshp_configuration set value = &#039;$4&#039; where NAME IN (&#039;PS_SHOP_DOMAIN&#039;, &#039;PS_SHOP_DOMAIN_SSL&#039;)&quot;
mysql -u $targetUser $targetName -p$targetPassword -e &quot;UPDATE prstshp_shop_url SET domain = &#039;$4&#039;, domain_ssl = &#039;$4&#039; WHERE id_shop_url = 1;&quot;
sed -i s/\\^$3\\$/^$4$/g $2/.htaccess

echo Terminado.
</pre>
<p>The implementation could undoubtedly be improved—using a more suitable language or more advanced tools—but this is the solution I came up with given the constraints of an environment lacking many essential utilities and commands. If you found it helpful, feel free to share your experience in the comments.</p>
<p>La entrada <a href="https://blog.krusher.net/en/2025/05/about-how-to-clone-a-prestashop-instance/">About how to clone a Prestashop instance</a> se publicó primero en <a href="https://blog.krusher.net/en">Nobody comes after the last</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.krusher.net/en/2025/05/about-how-to-clone-a-prestashop-instance/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
