Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic backup to S3 fails, manual backup works #475

Closed
denis-ev opened this issue May 26, 2022 · 6 comments · Fixed by #486
Closed

Automatic backup to S3 fails, manual backup works #475

denis-ev opened this issue May 26, 2022 · 6 comments · Fixed by #486
Labels
Bug Something isn't working

Comments

@denis-ev
Copy link

Describe the bug
I'm getting a mail that my backup failed and when I check, it did fail.
But when I'm manually running the backup docker-compose exec app php artisan backup:run it works without any errors.

The Backup is run via cron.

The Backups are set to upload to a S3 Storage.

This is the message I get per mail.

Exception message: mkdir(): Permission denied

Exception trace: 
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'mkdir(): Permis...', '/app/vendor/spa...', 43) 
#1 /app/vendor/spatie/temporary-directory/src/TemporaryDirectory.php(43): mkdir('/app/storage/ap...', 511, true) 
#2 /app/vendor/spatie/laravel-backup/src/Tasks/Backup/BackupJob.php(139): Spatie\TemporaryDirectory\TemporaryDirectory->create() 
#3 /app/vendor/spatie/laravel-backup/src/Commands/BackupCommand.php(56): Spatie\Backup\Tasks\Backup\BackupJob->run() 
#4 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Spatie\Backup\Commands\BackupCommand->handle() 
#5 /app/vendor/laravel/framework/src/Illuminate/Container/Util.php(40): Illuminate\Container\BoundMethod::Illuminate\Container{closure}() 
#6 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure(Object(Closure)) 
#7 /app/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure)) 
#8 /app/vendor/laravel/framework/src/Illuminate/Container/Container.php(653): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL) 
#9 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(136): Illuminate\Container\Container->call(Array) 
#10 /app/vendor/symfony/console/Command/Command.php(298): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) 
#11 /app/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle)) 
#12 /app/vendor/spatie/laravel-backup/src/Commands/BaseCommand.php(16): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#13 /app/vendor/symfony/console/Application.php(1015): Spatie\Backup\Commands\BaseCommand->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#14 /app/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand(Object(Spatie\Backup\Commands\BackupCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#15 /app/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#16 /app/vendor/laravel/framework/src/Illuminate/Console/Application.php(94): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#17 /app/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#18 /app/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput)) 
#19 {main}

docker-compose.yml

version: "3"

networks:
  traefik_network:
    external:
      name: proxy_traefik
  linkace_net:
    name: linkace_net

services:

  # --- MariaDB
  db:
    image: mariadb:10.7
    restart: unless-stopped
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
    networks:
      - linkace_net
    environment:
      - MYSQL_ROOT_PASSWORD=${DB_PASSWORD}
      - MYSQL_USER=${DB_USERNAME}
      - MYSQL_PASSWORD=${DB_PASSWORD}
      - MYSQL_DATABASE=${DB_DATABASE}
    volumes:
      - db:/var/lib/mysql

  # --- LinkAce Image with PHP
  app:
    image: linkace/linkace:v1.10.1
    restart: unless-stopped
    depends_on:
      - db
    networks:
      - linkace_net
    volumes:
      - ./.env:/app/.env
      - linkace_app:/app
      - linkace_logs:/app/storage/logs
      # Remove the hash of the following line if you want to use local backups
      # - ./data/backups:/app/storage/app/backups

  # --- nginx
  nginx:
    image: bitnami/nginx:1.21
    restart: unless-stopped
    #ports:
      #- "0.0.0.0:80:8080"
      #- "0.0.0.0:443:8443"
    depends_on:
      - app
    networks:
      - linkace_net
      - traefik_network
    volumes:
      - linkace_app:/app
      # Replace `nginx.conf` with `nginx-ssl.conf` and remove the hash from the following line
      # if you want to use HTTPS for this container
      - ./nginx.conf:/opt/bitnami/nginx/conf/server_blocks/linkace.conf:ro
      #- /path/to/your/ssl/certificates:/certs:ro
    labels:
      - "traefik.http.services.linkace.loadbalancer.server.scheme=http"
      - "traefik.http.services.linkace.loadbalancer.server.port=8080"
    ...

  # --- Redis
  redis:
    image: bitnami/redis:6.2
    restart: unless-stopped
    networks:
      - linkace_net
    environment:
      - REDIS_PASSWORD=${REDIS_PASSWORD}

volumes:
  linkace_app:
  linkace_logs:
  db:
    driver: local

.env (redacted)

## LINKACE CONFIGURATION

## Basic app configuration
COMPOSE_PROJECT_NAME=linkace
# The app key is generated later, please leave it blank
APP_KEY=app_key

## Configuration of the database connection
## Attention: Those settings are configured during the web setup, please do not modify them now.
# Set the database driver (mysql, pgsql, sqlsrv)
DB_CONNECTION=mysql
# Set the host of your database here
DB_HOST=db
# Set the port of your database here
DB_PORT=3306
# Set the database name here
DB_DATABASE=db_name
# Set both username and password of the user accessing the database
DB_USERNAME=db_user
DB_PASSWORD=db_password

## Redis cache configuration
# Set the Redis connection here if you want to use it
REDIS_HOST=redis
REDIS_PASSWORD=redis_password
REDIS_PORT=6379

## You probably do not want to change any values blow. Only continue if you know what you are doing.
# Configure various driver
SESSION_DRIVER=redis
LOG_CHANNEL=stack
BROADCAST_DRIVER=log
CACHE_DRIVER=redis
QUEUE_DRIVER=database

## Backup configuration
# Enable backups here
BACKUP_ENABLED=true
# Choose the destination of the backup. If you set up AWS S3 credentials below you may choose 's3' which is used
# as a synonym for AWS. Leave blank or set to 'local' if you want to store backups within /storage/app/backups.
BACKUP_DISK=s3
# Set to false if you do not want to be notified about successful or broken backups
BACKUP_NOTIFICATIONS=true
# The notification email may be used to get backup notifications
[email protected]
# Maximum size of all backups in megabytes
BACKUP_MAX_SIZE=512

AWS_ACCESS_KEY_ID=access_key
AWS_SECRET_ACCESS_KEY=secret_access_key
AWS_DEFAULT_REGION=region
AWS_BUCKET=bucketname
AWS_ENDPOINT=https://region.example.com

## Mail configuration
[email protected]
MAIL_FROM_NAME=LinkAce
# Set the driver used for sending email here, default is `smtp`
MAIL_DRIVER=smtp
# Set the SMTP host and its port here
MAIL_HOST=smtp.example.com
MAIL_PORT=25
# Set the username used to connect to the SMTP server here
MAIL_USERNAME=username
# Set the password used to connect to the SMTP server here
MAIL_PASSWORD=password
# If your SMTP server uses encrypted connections, enable it here by setting the variable to `tls`
MAIL_ENCRYPTION=tls

To Reproduce
Setup S3 backups, enable automatic backups via cron

Expected behavior
Successful backup

LinkAce setup (please complete the following information):

  • Version: 1.10.1
  • Installed via: Docker (linkace/linkace:v1.10.1)
  • OS: Ubuntu
@denis-ev denis-ev added the Bug Something isn't working label May 26, 2022
@Kovah
Copy link
Owner

Kovah commented May 26, 2022

This should be fixed already. Could you check #412?

@denis-ev
Copy link
Author

@Kovah
when I run the command docker exec linkace_app_1 ls -la /app/storage/app this is the output:

drwxrwxrwx    5 root     root          4096 May 14 05:01 .
drwxrwxrwx    6 root     root          4096 May 13 08:55 ..
-rwxrwxrwx    1 root     root            37 May  2 07:45 .gitignore
drwxr-xr-x    2 root     root          4096 May 25 08:10 backup-temp
drwxr-xr-x    2 root     root          4096 May 13 08:55 backups
drwxrwxrwx    2 root     root          4096 May 13 08:55 public

nothing changes when I run docker exec linkace_app_1 chmod +w /app/storage/app/backup-temp

when I run docker exec linkace_app_1 chmod 777 /app/storage/app -R on the other hand I change everything to read and write and executable

docker exec linkace_app_1 ls -la /app/storage/app

total 24
drwxrwxrwx    5 root     root          4096 May 14 05:01 .
drwxrwxrwx    6 root     root          4096 May 13 08:55 ..
-rwxrwxrwx    1 root     root            37 May  2 07:45 .gitignore
drwxrwxrwx    2 root     root          4096 May 25 08:10 backup-temp
drwxrwxrwx    2 root     root          4096 May 13 08:55 backups
drwxrwxrwx    2 root     root          4096 May 13 08:55 public

@Kovah
Copy link
Owner

Kovah commented May 26, 2022

Thanks for the information. Will have a look into this.

@denis-ev
Copy link
Author

I'll keep you updated if I get another error backup or if it's working now.

@denis-ev
Copy link
Author

It is working so far, after changing the permissions.

@Kovah
Copy link
Owner

Kovah commented Jun 10, 2022

For whatever reason, the backup-temp directory is missing from the image. I try to fix it and push an update with the next version.

@Kovah Kovah linked a pull request Jun 10, 2022 that will close this issue
@Kovah Kovah moved this to Released in LinkAce Development Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants