Hi Joe,

you could add a task

- name: Get current timestamp
  local_action: command bash -c "date +%Y-%m-%d.%H%M"
  register: now
  run_once: true

(or something similar adapted to your local environment) before your
dump task and then use {{ now }} in the next tasks to always get the
same timestamp.

Best,
Felix



On Thu, 21 Apr 2016 08:45:53 -0700 (PDT)
Joe Louthan <[email protected]> wrote:

> Hello,
> 
> In my deployments, I tend to do db backups and dump them into
> filenames containing a timestamp like so:
> 
> mysqldump dbname | gzip -9c > ~/dbname.`date +%Y-%m-%d.%H%M`.sql.gz ;
> ls -la ~/ | grep `date +%Y-%m-%d`
> 
> As you can see, when the dump is done, I want to see the resulting
> file just to eyeball it and make everything looks right.
> 
> (To answer future questions: we date time stamp our backup files so
> that we can keep them for an extended period of time.)
> 
> I would like to write something like this:
> 
> - hosts: dbserver
>   remote_user: jlouthan
>   tasks:
>       - name: Backup Prod Database
>         shell: mysqldump dbdump | gzip -9c > ~jlouthan/dbdump.`date 
> +%Y-%m-%d`.sql.gz
>         become: yes
>         become_method: sudo
> 
>       - name: Check to see if the dbdump has been successfully created
>         wait_for: path=~jlouthan/dbdump.`date +%Y-%m-%d`.sql.gz
> 
> 
> Is there any chance that Ansible would be able to pick up on
> backticks or is there a better way?
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20160421234129.25427d59%40fontein.de.
For more options, visit https://groups.google.com/d/optout.

Reply via email to