snipt

Ctrl+h for KB shortcuts

Bash

find files between a certain age or of a certain size

1
2
3
4
5
6
#find to delete files between a certain age
find . -mtime +90 -mtime -240 -type f -name \*tar.bz2 -exec ls -la {} \;

#find files within a particular file system of a certain size
# -mount tells it to ignore other mount points
find / -mount -type f | xargs du | sort -r -n -k 1 | head -n 10
https://snipt.net/embed/7292407f12337faa0cfc7d7a65eceb03/
/raw/7292407f12337faa0cfc7d7a65eceb03/
7292407f12337faa0cfc7d7a65eceb03
bash
Bash
6
2019-07-14T13:07:49
True
False
False
Aug 06, 2012 at 10:22 AM
/api/public/snipt/24741/
find-to-delete-files-between-a-certain-age
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1">#find to delete files between a certain age</span> </span><span id="L-2"><a name="L-2"></a>find . -mtime +90 -mtime -240 -type f -name <span class="se">\*</span>tar.bz2 -exec ls -la <span class="o">{}</span> <span class="se">\;</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1">#find files within a particular file system of a certain size</span> </span><span id="L-5"><a name="L-5"></a><span class="c1"># -mount tells it to ignore other mount points</span> </span><span id="L-6"><a name="L-6"></a>find / -mount -type f <span class="p">|</span> xargs du <span class="p">|</span> sort -r -n -k <span class="m">1</span> <span class="p">|</span> head -n 10 </span></pre></div> </td></tr></table>
backup, find

Bash

Remote Joomla backup using Akeeba

1
2
3
4
5
#!/bin/sh
#Remote backup of administered Joomla websites using Akeeba component

# Website1
wget --max-redirect=1000 --spider "http://www.website1.com/index.php?action=com_akeeba&view=backup&key=YOURKEY&format=raw"
https://snipt.net/embed/532943fe592d3c7b799cf7713590e157/
/raw/532943fe592d3c7b799cf7713590e157/
532943fe592d3c7b799cf7713590e157
bash
Bash
5
2019-07-17T09:42:36
True
False
False
/api/public/snipt/22490/
remote-joomla-backup-using-akeeba
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="ch">#!/bin/sh</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">#Remote backup of administered Joomla websites using Akeeba component</span> </span><span id="L-3"><a name="L-3"></a> </span><span id="L-4"><a name="L-4"></a><span class="c1"># Website1</span> </span><span id="L-5"><a name="L-5"></a>wget --max-redirect<span class="o">=</span><span class="m">1000</span> --spider <span class="s2">&quot;http://www.website1.com/index.php?action=com_akeeba&amp;view=backup&amp;key=YOURKEY&amp;format=raw&quot;</span> </span></pre></div> </td></tr></table>
akeeba, backup, joomla, server, shell

Bash

bash timestamp variable

$ timestamp=`date +%Y-%m-%d`
https://snipt.net/embed/eb10fc5079f4c1c18ce8a178759f8f36/
/raw/eb10fc5079f4c1c18ce8a178759f8f36/
eb10fc5079f4c1c18ce8a178759f8f36
bash
Bash
1
2019-07-16T22:26:21
True
False
False
/api/public/snipt/20779/
bash-timestamp-variable
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>$ <span class="nv">timestamp</span><span class="o">=</span><span class="sb">`</span>date +%Y-%m-%d<span class="sb">`</span> </span></pre></div> </td></tr></table>
backup, logs, script, time, timestamp

Bash

Offsite server backup config file

1
2
3
host ftphostaddress
user myusername
pass mypasswd
https://snipt.net/embed/e1759a68bdba04abdfb654c25efbb339/
/raw/e1759a68bdba04abdfb654c25efbb339/
e1759a68bdba04abdfb654c25efbb339
bash
Bash
3
2019-07-05T03:05:52
True
False
False
/api/public/snipt/20570/
offsite-server-backup-config-file
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>host ftphostaddress </span><span id="L-2"><a name="L-2"></a>user myusername </span><span id="L-3"><a name="L-3"></a>pass mypasswd </span></pre></div> </td></tr></table>
backup, linux, server

Bash

Crontab 1and1

1
2
3
4
5
6
7
8
# daily backup of my server
00 05 * * * $HOME/scripts/backup_server.sh
# daily remote backup of Joomla websites
00 05 * * * $HOME/scripts/joomla_remote_backup.sh
# weekly offsite backup of my server
00 06 * * 1 $HOME/scripts/backup_server_offsite.sh
# weekly offsite backup of Joomla websites
00 06 * * 1 $HOME/scripts/joomla_offsite_backup.sh
https://snipt.net/embed/a756f373818c9cbd32089fbcfe8bc0eb/
/raw/a756f373818c9cbd32089fbcfe8bc0eb/
a756f373818c9cbd32089fbcfe8bc0eb
bash
Bash
8
2019-07-15T14:05:16
True
False
False
/api/public/snipt/20569/
crontab-1and1
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="c1"># daily backup of my server</span> </span><span id="L-2"><a name="L-2"></a><span class="m">00</span> <span class="m">05</span> * * * <span class="nv">$HOME</span>/scripts/backup_server.sh </span><span id="L-3"><a name="L-3"></a><span class="c1"># daily remote backup of Joomla websites</span> </span><span id="L-4"><a name="L-4"></a><span class="m">00</span> <span class="m">05</span> * * * <span class="nv">$HOME</span>/scripts/joomla_remote_backup.sh </span><span id="L-5"><a name="L-5"></a><span class="c1"># weekly offsite backup of my server</span> </span><span id="L-6"><a name="L-6"></a><span class="m">00</span> <span class="m">06</span> * * <span class="m">1</span> <span class="nv">$HOME</span>/scripts/backup_server_offsite.sh </span><span id="L-7"><a name="L-7"></a><span class="c1"># weekly offsite backup of Joomla websites</span> </span><span id="L-8"><a name="L-8"></a><span class="m">00</span> <span class="m">06</span> * * <span class="m">1</span> <span class="nv">$HOME</span>/scripts/joomla_offsite_backup.sh </span></pre></div> </td></tr></table>
backup, cron, linux, server

Bash

Offsite Joomla backup

1
2
3
4
5
6
#!/bin/sh
#Offsite backup of administered Joomla websites
# content of secretpage.php available at http://snipt.net/tommybart2000/akeeba-offsite-ftp-backup-with-php-script/

# Website1
wget --spider "http://www.website1.com/backup/secretpage.php"
https://snipt.net/embed/10c4ff4eade491bd36a0724a8a5562c4/
/raw/10c4ff4eade491bd36a0724a8a5562c4/
10c4ff4eade491bd36a0724a8a5562c4
bash
Bash
6
2019-07-05T00:42:03
True
False
False
/api/public/snipt/20568/
offsite-joomla-backup
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="ch">#!/bin/sh</span> </span><span id="L-2"><a name="L-2"></a><span class="c1">#Offsite backup of administered Joomla websites</span> </span><span id="L-3"><a name="L-3"></a><span class="c1"># content of secretpage.php available at http://snipt.net/tommybart2000/akeeba-offsite-ftp-backup-with-php-script/</span> </span><span id="L-4"><a name="L-4"></a> </span><span id="L-5"><a name="L-5"></a><span class="c1"># Website1</span> </span><span id="L-6"><a name="L-6"></a>wget --spider <span class="s2">&quot;http://www.website1.com/backup/secretpage.php&quot;</span> </span></pre></div> </td></tr></table>
backup, cron, joomla, linux, server