Support

UNiTE, Remote CLI, eXtract Wizard

#3649 Move files out of backup directory with script

Posted in ‘UNiTE and Remote CLI’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

PHP version
n/a
Tool
UNiTE
Tool version
n/a

Latest post by nicholas on Monday, 21 June 2010 23:58 CDT

user6048
Hi:

I just used remote control (on Windows XP) for a site of mine and I love it. I am assuming it has to stay running (is not installed as a service). I love it so much I want to do the same for another site of mine, but things are a little different. I just saw that remote control can be installed on LINUX with supporting WINE so I installed WINE on my dedicated server. Installed akeeba remote control on my LINUX server but after looking at it, that's not what I really want. I logoff of the console so as to minimize all the memory being used when I'm logged in. So, another way to do it is to have the remote control that's already running on my windows xp machine do the backups (for the site hosted on my LINUX server) remotely but not do the download and delete from server option. Thing is, I have a terabyte backup drive hooked up to my LINUX server so I need for those backups on that machine to go to the terabyte backup drive on that particular server (all of these machine are on a home office network). So I thought I would simply write a PERL script to move the backup files from the backup directory to the backup drive on the LINUX server using crontab.

Can I just move the backup files out of the backup directory on the LINUX server with a move command from the command line? I did not know if I'd be messing up a db within Akeeba since it might keep track of those files. Also thought maybe Akeeba wouldn't like that I'm managing the backup files outside of the component. Another question: Can I delete all of those miscellaneous files in the backup directory? Example:

-rw-r--r-- 1 nobody nobody 48029495 2009-05-06 18:29 1a6b863d
-rw-r--r-- 1 nobody nobody 1462380 2010-06-16 21:43 joomlapack.log
-rw------- 1 nobody nobody 316071 2008-10-22 22:38 jpzcd20GG8S
-rw------- 1 nobody nobody 320799 2008-10-22 22:40 jpzcd2rS46H
-rw------- 1 nobody nobody 320799 2008-10-22 22:39 jpzcd3MgnvS
-rw------- 1 nobody nobody 316071 2008-10-22 22:39 jpzcd5GHh1F
-rw------- 1 nobody nobody 316071 2008-10-22 22:38 jpzcdHRV5YK
-rw------- 1 nobody nobody 316071 2008-10-22 22:39 jpzcdhxiTZV
-rw------- 1 nobody nobody 301827 2008-10-22 22:38 jpzcdkjUVEE
-rw------- 1 nobody nobody 282819 2008-10-22 22:38 jpzcdn50oll
-rw------- 1 nobody nobody 311355 2008-10-22 22:38 jpzcdo0yAKs
-rw------- 1 nobody nobody 320799 2008-10-22 22:38 jpzcdOFMghz
-rw------- 1 nobody nobody 320799 2008-10-22 22:39 jpzcdQaNAHy
-rw------- 1 nobody nobody 320799 2008-10-22 22:40 jpzcdrkMuMk
-rw------- 1 nobody nobody 316071 2008-10-22 22:39 jpzcdScjyOF
-rw------- 1 nobody nobody 7599 2009-05-06 18:16 jpzcdtICJIc
-rwxr-xr-x 1 nobody nobody 696738088 2010-06-14 08:14 site-www.mydomain.com-20100615-070312.jpa*
-rwxr-xr-x 1 nobody nobody 450707879 2010-06-19 09:18 site-www.mydomain.com-20100618-080306.jpa*

Also, that first file '1a6b863d' appears to be a sql dump. Can I delete it too? It's kinda big and I don't know why it's there. Of course I'll keep the log but if I'm moving backup files out of there then I should handle the "cleanup" as well.

Thanks again.

dlb
Remote is pretty awesome! :) There is an OS independent version under development. No more WINE! :D

You are sharing the tmp and Output folders, that is why you're getting the "garbage" files in Output. Akeeba tries to delete the temporary files, but on some server setups, it doesn't work. Akeeba tells the server to delete the file, the server reports the file successfully deleted, but it isn't. I believe that Nicholas has reproduced the problem, but can't figure out why it happens. The backup files and the log are the only important files in that folder.

You can manipulate the backup files outside of Akeeba. We recommend that the downloads be done via ftp, not via the download command on the Administer Backups screen. If you remove backup files from the Output folder, the backup changes status to "Obsolete". You can also move the file back and the Obsolete status should be replaced.


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

user6048
Awesome. That's all I need to know. As for the ftp, I didn't want to do it that way because there's no need to ftp. I'm doing this on a dedicated server in my home office. I have akeeba remote running on a windows xp machine that simply keeps running the backups, then I wrote a script and crontab to move the backup out of my site directory onto my backup drive (on my LAMP server). Although I know there's very, very, very few people out there doing what I'm doing, I figured I'd throw out what I did to make it happen. It's not bad at all.

I'm assuming you know some basics of UNIX and working with command prompts:

1. Edit your crontab
crontab -e

add the following line:

0 9 * * 4 /etc/backupakeeba.sh 2>&1 | mail -s "Moved backup to USB drive" [email protected]

You'll have to google crontab to modify the first part of that line to match your backup schedule. If VI is your default editor you'll have to know a thing or two about VI. I only want to do backups at 9am every Thursday. Then it emails me the output, if any, of the move.

2. Then create the script. It will take the newest backup file in the akeeba directory and move it (not copy but move) to your backup drive. Content of script /etc/backupakeeba.sh:

#!/bin/sh

latest_file=`ls -1tr /home/mysite/www/administrator/mybackupdirecotry | tail -n 1`

mv /home/mysite/www/administrator/mybackupdirecotry/$latest_file /myusbdrive/backups

This will prevent the accumulation of backup files in your akeeba directory, while moving the newest backup file to your backup drive..

dlb
Thank you for documenting the technique!

If VI was my editor, I would have to go back to Windows or shoot myself. I can't decide which is preferable. :D


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

nicholas
Akeeba Staff
Manager
@mrealty Just one small note. The ls/tail technique only returns the latest file. If you try to do that with split archives it won't work ;) Other than that it's a cool technique!

@dlb I'd rather pull my eye off its socket with a spoon rather than be condemned to use vi as my primary editor. It's very powerful, but I think I killed quite a few braincells trying to memorize its commands. I prefer joe on the command line and gedit (or kate, if I'm working in KDE) from a desktop environment.

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

user6048
True. Works for single archives - not split (I can't cover all the bases - just my own :) ).

@VI: Comon' guys. I remember back in the days of DOS. We were using edlin and copy con. To this day I still use copy con because it's quick, I type fast, and don't have all day. Yes, VI is tough... but when you're used to it's not so bad...kinda like being married. :)

dlb
Notepad: the editor from the people who brought us edlin!

LOL I never thought about it like that before, but I see some similarities. Like marriage, no one can master the command syntax. :D I can say that because my wife doesn't know where the forum is.


Dale L. Brackin
Support Specialist


us.gifEnglish: native


Please keep in mind my timezone and cultural differences when reading my replies. Thank you!


????
My time zone is EST (UTC -5) (click here to see my current time in Philadelphia, PA)

nicholas
Akeeba Staff
Manager
LoL! I never liked edlin. The first thing I did when bought my first PC in 1992 was to find a descent text editor. I do use vi for editing the configuration files on my Ubuntu Server box over SSH, but it's not something I enjoy very much. I only know about 1% of vi's commands by heart. If I want anything else I have to read through the manual. This beats the purpose, so I stick with joe for larger edit jobs.

Well, text editors are like cars. Everyone likes a different kind. The Emacs vs. VI users thing is as fierce as Mercedes vs. BMW drivers thing :)

Nicholas K. Dionysopoulos

Lead Developer and Director

πŸ‡¬πŸ‡·Greek: native πŸ‡¬πŸ‡§English: excellent πŸ‡«πŸ‡·French: basic β€’ πŸ• My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!