Export all projects

Hi,
How can I export all the tasks from all the projects into a CSV (as opposed to going into each project separately)
TIA!

Are you looking for a response that involves code or not?

If so, I wont do it for you, but can at least point you in the right direction, or at least A direction.

Here is your magic:

Now, with some understanding of kanboards code, its fairly simple to make it do what you want.

If you also take a look at metamagik, you’ll see how to utilize your own custom export, and integrate into plugin format.

For non code, use something like phpmyadmin.

1 Like

Thanks for your quick and detailed response!

Can you expand a bit on the non code options?

Stumbled across the command line interface (cli) in the installation guide.
There is a command like
./cli export:subtasks <project_id> <start_date> <end_date>
e.g.
./cli export:tasks 1 2014-10-01 2014-11-30 >/tmp/my_custom_export.csv would export for table No 1.
Now with a shell script which traverses all project numbers you may get what you want.
Did not try if it works, though, and it is nothing a normal user can do.

With phpmyadmin or phpliteadmin, depending on which DB type you are using, you can just run sql queries to get what you want, out of the database, and then export.

1 Like

Thanks but that won’t work. It will generate a different csv for each project and I need them all in one file.

Thanks! will try that

If you use in your shellscript “>>” instead of “>” it will append to the file instead of overwrite.

image001.jpg

Honestly, the code is the simplest of all solutions. Probably, 3 lines.

Get all the project ids, and iterate through them all…

Might seem scary to you, i don’t know, but it really shouldn’t be.

    public function export($from, $to) <---remove $project_id here
    {
        $projects = $this->projectModel->getAllIds(); <---get all the project ids here
        $results = array($this->getColumns());  <--need to move this out of the iteration
        foreach ($projects as $project_id) {  <--- start the iteration here
          $tasks = $this->getTasks($project_id, $from, $to);
          $taskIds = array_column($tasks, 'id');
          $tags = $this->taskTagModel->getTagsByTaskIds($taskIds);
          $colors = $this->colorModel->getList();
         

          foreach ($tasks as &$task) {
              $task = $this->format($task, $colors, $tags);
              $results[] = array_values($task);
          }
    } <---end iteration here

        return $results;
    }

should work, been a long time since i have looked at the code, but 99% sure its that simple. and yeah, so that’s 3 lines, and 1 small edit to another line, while moving another line outside the iteration…if you want, you could just edit that code directly, which would be a hack (and you would have to undo it, if you ever want the original version export function to work again), but would get you what you want, or you could litterlly go the extra mile and create a link somewhere in a template to add this export and make a little plugin. MetaMagik would be your guide on how to utilize your own Export, which I could explain if you want, it would also be very minimal effort of code, and the only difference would be that you need to add the export option instead of overriding the current one.

1 Like

@creecros you’ve just coded more than a code snippet for a plug-in that would mean to do that! Congrats!